Skip to content

Strange traceback with WebSocket.send #73

@vincent-lg

Description

@vincent-lg

I use ws4py with Cherrypy (the plugin and the tool provided).

It works just fine most of the time, but sometimes I have in my log a traceback like that. I didn't remove any line from it, more explanations are given below:

Exception in thread WebSocket client at _..**.**_:56741:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/threading.py", line 639, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.3/threading.py", line 596, in run
self._target(_self._args, *_self._kwargs)
File "/usr/local/lib/python3.3/site-packages/ws4py-0.2.5-py3.3.egg/ws4py/websocket.py", line 291, in run
if not process(bytes):
File "/usr/local/lib/python3.3/site-packages/ws4py-0.2.5-py3.3.egg/ws4py/websocket.py", line 343, in process
self.received_message(s.message)
File "/home/vlegoff/pa-poc2/scripts/../plugins/websocket/handler.py", line 86, in received_message
function(**args)
File "/home/vlegoff/pa-poc2/scripts/../bundles/chat/websockets/chat.py", line 32, in handle_setpseudo
self.send_to_connected(welcome, self)
File "/home/vlegoff/pa-poc2/scripts/../bundles/chat/websockets/chat.py", line 58, in send_to_connected
ws_handler.send_message(message, escape=escape)
File "/home/vlegoff/pa-poc2/scripts/../bundles/chat/websockets/chat.py", line 69, in send_message
self.send_JSON("message", message=message)
File "/home/vlegoff/pa-poc2/scripts/../plugins/websocket/handler.py", line 110, in send_JSON
self.send_text(text)
File "/home/vlegoff/pa-poc2/scripts/../plugins/websocket/handler.py", line 101, in send_text
self.send(msg)
File "/usr/local/lib/python3.3/site-packages/ws4py-0.2.5-py3.3.egg/ws4py/websocket.py", line 219, in send
message_sender = self.stream.binary_message if binary else self.stream.text_message
AttributeError: 'NoneType' object has no attribute 'text_message'

The almost last lines are part of my application: I have a WebSocketHandler (the Chat class inherited from WebSocket defined in ws4py). The goal is to send a message to one of the connected client and it finally crashes on the WebSocket.send method.

Do you know why this happens and how to fix it? Is it a ws4py bug or a wrong usage in my application?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions