Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Can't access from behind proxy #31

Closed
asarchami opened this issue Apr 14, 2017 · 4 comments
Closed

Can't access from behind proxy #31

asarchami opened this issue Apr 14, 2017 · 4 comments

Comments

@asarchami
Copy link

I'm trying to use python behind proxy and I get this error:

HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /api/views/hdsc-ubkz.json (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fc509240110>: Failed to establish a new connection: [Errno 113] No route to host',))

Is there a way to specify proxy settings with sodapy?

@timwis
Copy link
Collaborator

timwis commented Apr 15, 2017

sodapy uses the python library requests to make HTTP requests. According to the requests documentation, you can pass proxy settings as an argument (which would require modifying sodapy), or you can set environment variables, which should work without modifying sodapy. Can you try setting the environment variables? The example they give is for mac/linux, but you can do it in windows with a slightly different syntax that I don't recall off-hand.

@xmunoz
Copy link
Owner

xmunoz commented May 14, 2017

Any luck with @timwis's suggestion, @asarchami? I feel like the environment variable is a good compromise, but if that doesn't work, it shouldn't be too hard to set a proxy argument in the client that is transparently passed to the requests library.

@asarchami
Copy link
Author

Environment variables didn't work for me. I haven't try sodapy since but according to my past experience I have to pass proxy settings as an argument. My working environment and proxy is kind of weird.

@xmunoz
Copy link
Owner

xmunoz commented May 17, 2017

I busted out tcpdump and did manage to get this working with a proxy through environment variables. Something important to note is that sodapy connects via https by default, so the environment variable needs to be something like os.environ["HTTPS_PROXY"] = "https://13.74.23.178:3128", otherwise you will experience the errors above. If your proxy doesn't support https, you can set the client to connect with http by configuring your own adapter.

from requests.adapters import HTTPAdapter
myadapter = {}
myadapter["prefix"] = "http://"
adapter = HTTPAdapter()
myadapter["adapter"] = adapter
client = Socrata(DOMAIN, APPTOKEN, session_adapter=myadapter)

Can you try something like what I described above and let me know how it goes?

Edit: I should probably add something to the documentation about this...

@xmunoz xmunoz closed this as completed in a4558e6 May 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants