From b947318142bfd999b44799c48765e3e22bbaff7e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 2 Aug 2022 19:50:04 +0300 Subject: [PATCH] Close producer when dispatcher close the window --- public/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/index.js b/public/index.js index 4db5e57..a8e748b 100644 --- a/public/index.js +++ b/public/index.js @@ -15,7 +15,12 @@ hub = io(config.hubAddress) const connectToMediasoup = () => { - socket = io(config.mediasoupAddress) + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity + }) socket.on('connection-success', ({ _socketId, existsProducer }) => { console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) @@ -63,6 +68,10 @@ if (IS_PRODUCER === true) { socket.emit('transportclose') consumer = null producer = null + producerTransport = null + consumerTransport = null + device = null + socket.destroy() } }) })