Any way to reconnect when node restarts

I'm currently using the reconnect: { basic: whatever } property in my nodes. While this works whenever the node requests a websocket reconnect it doesn't attempt to reconnect whenever the node is restarting
20 Replies
viztea
viztea3y ago
lavalink doesn't request reconnects could you elaborate? I'll probably have to port over the nodejs reconnection logic anyways
Bloxs
BloxsOP3y ago
Whenever the socket reconnects Any updates regarding this? As it’s fairly inconvenient for me to restart the bot whenever lavalink gets restarted
viztea
viztea3y ago
yeah sorry, I'll look into it right now
Bloxs
BloxsOP3y ago
It’s fine, it hasn’t gotten on my nerves to the point I wrote my own reconnect function like I’ve done before it other issues lol
viztea
viztea3y ago
looks to be an issue with the ws lib doesn't catch closes Love how Deno has completely removed websockets from their stdlib
Bloxs
BloxsOP3y ago
iirc they replaced it with a upgradeWebsocket method on the Deno namespace where you provide a http request, it's a bit jank though
viztea
viztea3y ago
That would probably be better than me just writing my own ws lib pretty sure that's for the server though yeah incoming http request the only client-side websocket class is through web apis and that doesn't support headers
Bloxs
BloxsOP3y ago
The Websocketstream api supports headers, although that's probably gonna take more work to implement than just writing a custom socket wrapper
viztea
viztea3y ago
hmm it's also unstable
Bloxs
BloxsOP3y ago
Sockets don't seem to be getting much attention in deno as a whole, pogsockets was the only working one I could find that actually somewhat worked
viztea
viztea3y ago
i copied it from the stdlib before they removed it
Bloxs
BloxsOP3y ago
there's other solutions but they either don't work or have conflicting docs (references code that doesn't exist in the library) it's been a mess, I may investigate websocketsteam one day as socketio is a library I used a ton and having an alt for deno would be nice
viztea
viztea3y ago
I'll probs write my own ws lib one day rn im just gonna copy stuff over from the stdlib
Bloxs
BloxsOP3y ago
apparently if all you're using headers for is auth then you can do var ws = new WebSocket("ws://username:[email protected]/service"); or var ws = new WebSocket("ws://[email protected]/service"); seems kinda dumb though that even with the web standard there's no official way to add headers
viztea
viztea3y ago
Lavalink requires other headers User-Id, Client-Name etc So found the issue When the server doesn't send a close frame the socket just dies And I don't handle that
viztea
viztea3y ago
No description
viztea
viztea3y ago
should just be able to publish this and fix your issue
viztea
viztea3y ago
there we go
No description
Bloxs
BloxsOP3y ago
ty
Want results from more Discord servers?
Add your server