proper auto-reconnection from sockets
See original GitHub issueHi Jan,
Here’s how we do the connection / reconnection to sockets in F#:
let rec subscribeToTrades () =
let r =
socketClient.SubscribeToAggregatedTradeUpdatesAsync(symbol, fun trade -> tradesProcessor.Post(trade))
|> Async.AwaitTask
|> Async.RunSynchronously
if not r.Success then failwithf "couldn't subscribe to trades updates - %i:%s" r.Error.Code r.Error.Message
else
r.Data.add_ConnectionLost (fun _ -> eprintfn "%A - trades socket connection lost" DateTime.UtcNow)
r.Data.add_ConnectionRestored (fun _ -> eprintfn "%A - trades socket connection restored" DateTime.UtcNow
subscribeToTrades())
as you wrote the lib, could you confirm if this is optimal, or if there would be something you’d do differently when it comes to the subscription / reconnection mechanism?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
The right way for a client to reconnect after the server does ...
Server: node + socket.io var io = require( 'socket.io' )( 3000 ); io.on( ... I upgraded to version 2.0.3 and its default autoreconnect...
Read more >javascript - Socket IO reconnect?
The right way to fix it is: var io = null; DB.connect(function () { io = require('socket.io').listen(8080); io.sockets.on('connection', ...
Read more >TIP: Auto Reconnect Web Socket
With the latest update to the WebSocket cn1lib we now have a better solution: autoReconnect(int) . It's exactly as it sounds, once you...
Read more >The Socket instance (client-side)
The Socket instance emits three special events: connect; connect_error; disconnect. Please note that since Socket.IO v3, the Socket instance ...
Read more >Scaling Socket.IO - practical considerations
Regardless of how good your hardware is, you can only scale it vertically up to a finite capacity. What happens if, at some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, listenkey should indeed be handled manually. The advise is to call KeepAlive every 30 minutes, but I don’t think there is any downside to calling it every 10 minutes. I think you only get the listen key expired after 60 minutes without keep alive, so you shouldn’t run into that.
Looks just fine the way you’re handling it.
actually a related question: do you handle the listen key directly too, for the SubscribeToUserDataUpdatesAsync call?
right now I resubscribe when if the license key is expired.
I do something like this:
I also have this that goes with it: