python-socketio icon indicating copy to clipboard operation
python-socketio copied to clipboard

Unexpected exception in keepalive ping task & websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason

Open oujibahei opened this issue 7 years ago • 5 comments

2019-05-17 21:36:26,079 - protocol.py - line:1000 - keepalive_ping - WARNING - Unexpected exception in keepalive ping task Traceback (most recent call last):
  File "C:\IPA\env\lib\site-packages\websockets\protocol.py", line 984, in keepalive_ping
    ping_waiter = yield from self.ping()
  File "C:\IPA\env\lib\site-packages\websockets\protocol.py", line 583, in ping
    yield from self.ensure_open()
  File "C:\IPA\env\lib\site-packages\websockets\protocol.py", line 658, in ensure_open
    ) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason

Every time a script running more than 60s this error appears. The connection is lost and message emitting lost as well. Can anybody help or explain it? Thx.

oujibahei avatar May 17 '19 13:05 oujibahei

The error occurs in a dependency, not on this package. My guess is that your client or maybe an intermediary between the client and the server are closing the connection due to having a timeout configured. For WebSocket connections the timeouts need to be disabled, since obviously the connection is long lived.

miguelgrinberg avatar May 17 '19 16:05 miguelgrinberg

It seems that I don't have the access to disable the timeouts of WebSocket because socketio doesn't expose this interface?!

oujibahei avatar May 22 '19 06:05 oujibahei

Also I found an warning from WebSocket prior to the error above. 2019-05-22 15:21:39,723 - connectionpool.py - line:274 - _put_conn - WARNING - Connection pool is full, discarding connection: localhost 2019-05-22 15:21:39,723 - client.py - line:486 - _handle_eio_disconnect - INFO - Engine.IO connection dropped

oujibahei avatar May 22 '19 08:05 oujibahei

I meant timeouts imposed by clients or more likely intermediaries such as nginx, etc. The websocket server does not have timeouts, because as I said, they make no sense for this type of protocol.

miguelgrinberg avatar May 22 '19 08:05 miguelgrinberg

Sorry, I just realize that you are probably using the socket.io client, not the server. My comment still applies, there might be something in between your client and the server that is closing the connection after some timeout.

miguelgrinberg avatar May 22 '19 09:05 miguelgrinberg