I'm running an Autobahn WS server and am connecting to it from a client using the Python websocket-client (https://pypi.python.org/pypi/websocket-client/).
My client code is pretty simple :-
from websocket import create_connection
# WS_URL is a valid endpoint
ws = None
try:
ws = create_connection(WS_URL)
except:
print 'Could not connect to websocket server ...'
sample_message = "Hello world"
while True:
if ws is not None:
ws.send(sample_message)
This works fine for a while but then I see the error :-
error: [Errno 104] Connection reset by peer
Searching around, it seems related to a timeout error of some kind. Can anyone suggest how to fix this ?
UPDATE
Just to confirm the server side, the WS server is simply using the stock "broadcast" example from the Autobahn docs - https://github.com/tavendo/AutobahnPython/blob/master/examples/websocket/broadcast/server.py. So messages received from a client are just echoed back out to all connected clients.
UPDATE2
Thanks for the debug tip. I ran this and, when the error occurred, this is the output from the debug trace :-
2013-10-16 12:47:47+0000 [BroadcastServerProtocol,0,172.20.12.9] WebSocketProtocol.onClose:
wasClean=False
code=1006
reason=connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
self.closedByMe=False
self.failedByMe=False
self.droppedByMe=False
self.wasClean=False
self.wasNotCleanReason=peer dropped the TCP connection without previous WebSocket closing handshake
self.localCloseCode=None
self.localCloseReason=None
self.remoteCloseCode=None
self.remoteCloseReason=None
Why was the connection dropped ? The error can be reproduced and occurs after approx. the same time each run (~ 5 hours).