sockjs-tornado icon indicating copy to clipboard operation
sockjs-tornado copied to clipboard

Happened easily AssertionError at websocket.py when connection over 20 clients.

Open dewsxc opened this issue 7 years ago • 3 comments

When I try to send data to each connection, it is easily to occur AssertionError when sending.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "fto.py", line 38, in run
    self.send_message()
  File "fto.py", line 79, in send_message
    c.send(arr)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sockjs/tornado/conn.py", line 49, in send
    self.session.send_message(message, binary=binary)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sockjs/tornado/session.py", line 322, in send_message
    self.send_jsonified(proto.json_encode(bytes_to_str(msg)), stats)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sockjs/tornado/session.py", line 337, in send_jsonified
    self.handler.send_pack('a[%s]' % msg)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sockjs/tornado/transports/websocket.py", line 86, in send_pack
    self.write_message(message, binary)
  File "/usr/local/lib/python3.5/site-packages/tornado/websocket.py", line 252, in write_message
    return self.ws_connection.write_message(message, binary=binary)
  File "/usr/local/lib/python3.5/site-packages/tornado/websocket.py", line 783, in write_message
    message = self._compressor.compress(message)
  File "/usr/local/lib/python3.5/site-packages/tornado/websocket.py", line 548, in compress
    assert data.endswith(b'\x00\x00\xff\xff')
AssertionError

dewsxc avatar May 24 '17 05:05 dewsxc

I faced this issue as well. In my case it were just a 2-3 connections. Not as many as 15-20 connections.

vishal733 avatar Jun 20 '18 18:06 vishal733

12346 ERROR:2018-08-24 01:01:59,202:get_broadcast
12347 Traceback (most recent call last):
12348   File "/release/manik/muTrade-1.0.0-1.7.4.5/web/utrade/WebSocket/get_broadcast.py", line 321, in _send_msg_to_clients
12349     socketConnectionObject.send(smart_str(simplejson.dumps(data)))
12350   File "/release/st01/py3Env/lib/python3.6/site-packages/sockjs/tornado/conn.py", line 49, in send
12351     self.session.send_message(message, binary=binary)
12352   File "/release/st01/py3Env/lib/python3.6/site-packages/sockjs/tornado/session.py", line 322, in send_message
12353     self.send_jsonified(proto.json_encode(bytes_to_str(msg)), stats)
12354   File "/release/st01/py3Env/lib/python3.6/site-packages/sockjs/tornado/session.py", line 337, in send_jsonified
12355     self.handler.send_pack('a[%s]' % msg)
12356   File "/release/st01/py3Env/lib/python3.6/site-packages/sockjs/tornado/transports/websocket.py", line 86, in send_pack
12357     self.write_message(message, binary)
12358   File "/release/st01/py3Env/lib/python3.6/site-packages/tornado/websocket.py", line 252, in write_message
12359     return self.ws_connection.write_message(message, binary=binary)
12360   File "/release/st01/py3Env/lib/python3.6/site-packages/tornado/websocket.py", line 783, in write_message
12361     message = self._compressor.compress(message)
12362   File "/release/st01/py3Env/lib/python3.6/site-packages/tornado/websocket.py", line 548, in compress
12363     assert data.endswith(b'\x00\x00\xff\xff')
12364 AssertionError

garg10may avatar Aug 24 '18 11:08 garg10may

This is happening inside of the Tornado websocket library after attempting to compress the message before sending it over the TCP socket. I doubt it has something to do with sockjs-tornado, to be honest.

mrjoes avatar Aug 24 '18 13:08 mrjoes