Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout

Rekha
There is no logic in the on_ticks() function. It just collects ticks and add them to a global list.
def on_ticks(ws, ticks):
global my_ticks
my_ticks.extend(ticks)
kws.connect(threaded=True)

Still sometimes (not always), I get this error:
Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))

why so? Any solution?

  • Rekha
    I was assigning the callbacks inside a thread. That was the problem. I was working on a telegram bot and I created a command which creates a thread in which I was assigning the callbacks. That made connection very weak (for unknown reasons). As solution, I created a command which calls a function in which I assign the callbacks, then I create and run a thread which runs the logic.
This discussion has been closed.