Question

I'm trying to run Twython behind a proxy. Here are the client_args:

client_args = {
'verify': False,
'headers': {
    'User-Agent': 'AgentName'
},
'proxies': {
    'http': 'proxy:port_number',
    'https': 'proxy:port_number'
},
'timeout': 120
}

Running anything from the API runs into this error:

[Errno 1] _ssl.c:503: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Any workaround is really appreciated!

Was it helpful?

Solution

You've run into one of the problems with Requests which is that it cannot handle the CONNECT HTTP command, primarily because urllib3 doesn't support it. This article goes into more detail about the reasons for this and why urllib3 has not been updated to handle this. The article also includes an unsafe (and not recommended) work around you can try:

proxies = {'https': 'http://127.0.0.1:8080'}

Obviously replace the IP and port with whatever the settings your proxy server has.

You might also want to look at this question, which addresses the same error with httplib and some solutions that worked there and might be adaptable. Maybe.

EDIT: You're missing a comma after the second proxy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top