Websocket connection times out after 10-15 minutes despite replying to PINGs

Try your code on another server?
Ask your server provider about routing issues (some might not even allow IRC type stuff running and thats the issue you are having it’s getting shutdown by the provider)?
If you use digital ocean, they seem to have routing issues quite often