Connection lost azure webpubsub socketio / nodejs
Koen Bonenkamp
5
Reputation points
After some inactivity (e.g. computer goes into sleep modus) the connection to azure socket io hub gets lost. My express server functions normally so http requests are served but clients can't connect to the hub anymore as they get the message there is no backend service connected to the hub.
How can I prevent this loss of connection or at least automatically reconnect when it happens? I tried to listen to disconnect events but they are not triggered when the connection gets lost.
const httpServer = createServer(app)
export let io
async function main() {
const socketIOAzure = require('socket.io')
io = await socketIOAzure(httpServer).useAzureSocketIO({ hub, connectionString })
io.httpServer.listen(port, () => log({ level: 'info', message: `Server is running on port ${port}` }))
}
main()
Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
98 questions
Azure | Azure Startups
837 questions
Sign in to answer