ig-python / trading-ig

A lightweight Python wrapper for the IG Markets API
https://trading-ig.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
308 stars 196 forks source link

Communication Error / ConnectionResetError: [Errno 104] Connection reset by peer #297

Closed new-to-python99 closed 10 months ago

new-to-python99 commented 11 months ago

It looks like this was raised 2 years ago, without a solution, but the Communication error still sometimes occurs, with no obvious way to reconnect.

Here is the stack trace:

ERROR:trading_ig.lightstreamer:Communication` error
Traceback (most recent call last):
  File "/usr/local/AppCentral/python3/lib/python3.7/site-packages/trading_ig/lightstreamer.py", line 337, in _receive
    message = self._read_from_stream()
  File "/usr/local/AppCentral/python3/lib/python3.7/site-packages/trading_ig/lightstreamer.py", line 171, in _read_from_stream
    line = self._stream_connection.readline().decode("utf-8").rstrip()
  File "/usr/local/AppCentral/python3/lib/python3.7/http/client.py", line 667, in readline
    result = self.fp.readline(limit)
  File "/usr/local/AppCentral/python3/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/AppCentral/python3/lib/python3.7/ssl.py", line 1049, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/AppCentral/python3/lib/python3.7/ssl.py", line 908, in read
    return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

Can we get an on_error method or similar added to the LSClient class, so we can then re-connect / re-subscribe on error (or better still can we get a reconnect method)?

bug-or-feature commented 10 months ago

I'm closing this. The latest release uses the official Lightstreamer Python client SDK, which does auto-reconnections, auto-resubscriptions. See #302