websocket-client: AttributeError: 'NoneType' object has no attribute 'connected'

My on_open callback sends some data to the server when the connection is established. Usually, it works, but some times i receive the following error.

The following exception is captured in the on_error callback.

Traceback (most recent call last):
  File "[...]/python3.5/site-packages/websocket/_app.py", line 278, in run_forever
    dispatcher.read(self.sock.sock, read)
  File "[...]/python3.5/site-packages/websocket/_app.py", line 48, in read
    while self.app.sock.connected:
AttributeError: 'NoneType' object has no attribute 'connected'

I’m afraid I cannot provide more useful data to reproduce the problem as it appears to be raised randomly.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19

Commits related to this issue

Most upvoted comments

I have the same problem when I close socket.

    def on_message(ws: WebSocketApp, message):
        print(message)
        ws.close()

    def on_error(ws, error):
        print(error)

It triggers on_error: ‘NoneType’ object has no attribute ‘connected’