One of my websockets just received the following on_close message:
2023-07-27 15:50:27:root:INFO: Closed Connection, Status Code: 1001, Message: CloudFlare WebSocket proxy restarting
I need to understand what this message means so I can diagnose why the websocket did not reconnect. Can you explain why this message would be sent?
At the top of this page is the message ‘USE HEARTBEATS TO KEEP ALL SUBSCRIPTIONS OPEN: Most channels close within 60-90 seconds if no updates are sent. Subscribe to heartbeats to keep all subscriptions open.’
I was not using heartbeats at the time. Is that the reason the websocket was closed or is it something else?
I found the solution to this problem at this link: Websocket didn't restart · Issue #873 · websocket-client/websocket-client · GitHub
" Status code 1001
indicates that an endpoint is "going away" from the spec. This means the server is closing the connection.
The README says that
run_forever does not automatically reconnect if the server closes the WebSocket gracefully, so in the event that the server closes the connection you can specify the behavior that you want in the proper callback."
So the server closed the connection and I didn’t have a callback function implemented. Also I wasn’t running heartbeat, so I’ll implement those. So I don’t need help with this anymore. Thanks.
We’re glad that things worked out for you and thank you for letting us know about this.