Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionError #215

Closed
JoeSchm opened this issue Dec 31, 2017 · 3 comments
Closed

ConnectionError #215

JoeSchm opened this issue Dec 31, 2017 · 3 comments

Comments

@JoeSchm
Copy link

JoeSchm commented Dec 31, 2017

I uninstalled gdax and reinstalled the latest from github in hopes of better error handling from the API. All I'm really using are the public client and the authenticated client. Now I've had this traceback pretty quickly when I run my trading loops. Anyone know what the cause is or what I could do to avoid? Thanks,

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 284, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7eec28d71048>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 423, in send
timeout=timeoutNow I've had this traceback pretty quickly:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.gdax.com', port=443): Max retries exceeded with url: /products/ETH-USD/ticker (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7eec28d71048>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/lib/python3.6/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/home/xxxxx/Code/gdax-python-master/gdax/bot4.py", line 49, in
x_check=public_client.get_product_ticker('ETH-USD')
File "/usr/local/lib/python3.6/site-packages/gdax-1.0.6-py3.6.egg/gdax/public_client.py", line 119, in get_product_ticker
return self._get('/products/{}/ticker'.format(str(product_id)))
File "/usr/local/lib/python3.6/site-packages/gdax-1.0.6-py3.6.egg/gdax/public_client.py", line 33, in _get
r = requests.get(self.url + path, params=params, timeout=30)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.gdax.com', port=443): Max retries exceeded with url: /products/ETH-USD/ticker (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7eec28d71048>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

@JoeSchm
Copy link
Author

JoeSchm commented Dec 31, 2017

Also, sometime I'm getting the below error. It only happened today. Most of the time there is no issue with this 'price'. THanks

Traceback (most recent call last):
File "/usr/local/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/lib/python3.6/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/home/xxxxx/Code/bot3.py", line 50, in
x_price_check = float(x_check['price'])
KeyError: 'price'

@emestee
Copy link

emestee commented Jan 2, 2018

This looks like your DNS is unreliable. If you want automated trading and running over REST APIs, you probably should run a caching DNS forwarder locally, that'll shave off some milliseconds off your requests.

@danpaquin
Copy link
Owner

danpaquin commented Mar 23, 2018

Hey Joe, if you have unreliable connections, I would ensure each packet is returned as expected. I would pass your responses through an if statement to check for expected data and discard the response otherwise. In the meantime, we'll be adding tests and error handling through PR #260 so please follow that thread for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants