martin-ueding / vigilant-crypto-snatch

A little program that observes the current market price for your choice of currency pairs, looks for drastic reductions (dips) and then places buy orders.
https://martin-ueding.github.io/vigilant-crypto-snatch/
21 stars 5 forks source link

ConnectionError not handled in watch loop #22

Closed martin-ueding closed 2 years ago

martin-ueding commented 2 years ago

In the watch loop there is an unhandled exception kind.

Unhandled exception type: ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))). Please report this to Martin!

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/watchloop.py", line 52, in process_trigger
    if trigger.has_cooled_off(now) and trigger.is_triggered(now):
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/triggers/concrete.py", line 71, in is_triggered
    return self.triggered_delegate.is_triggered(now)
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/triggers/triggered_delegates.py", line 29, in is_triggered
    price = self.source.get_price(now, self.coin, self.fiat)
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/historical/concrete.py", line 107, in get_price
    price = live_source.get_price(then, coin, fiat)
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/historical/concrete.py", line 77, in get_price
    price = self.market.get_spot_price(coin, fiat, then)
  File "/usr/local/lib/python3.9/dist-packages/vigilant_crypto_snatch/marketplace/krakenex_adaptor.py", line 54, in get_spot_price
    answer = self.handle.query_public(
  File "/usr/local/lib/python3.9/dist-packages/krakenex/api.py", line 162, in query_public
    return self._query(urlpath, data, timeout = timeout)
  File "/usr/local/lib/python3.9/dist-packages/krakenex/api.py", line 134, in _query
    self.response = self.session.post(url, data = data, headers = headers,
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))