meetecho / janode

A Node.js adapter for the Janus WebRTC server
ISC License
98 stars 36 forks source link

Question: why does `Janode setup error` force the websocket connection to be closed? #4

Closed alvitoraidhy closed 2 years ago

alvitoraidhy commented 2 years ago

Hi. I was developing an app with Janode and by mistake I tried to connect to a nonexistent room. However I didn't expect the error to make the websocket close itself without reconnecting. I'm using this connection for all of my sessions and this just closes them all basically. May I know the reason for that and how can I stop it to close?

backend_1   | 2022-03-07T13:03:19.911Z - INFO : [transport-ws.js] [8999818924408386] closing websocket
backend_1   | error while joining a tour:  Error: 426 No such room (5332351842943423)
backend_1   |     at VideoRoomHandle.handleMessage (file:///usr/src/server/node_modules/janode/src/plugins/videoroom-plugin.js:304:33)
backend_1   |     at VideoRoomHandle._handleMessage (file:///usr/src/server/node_modules/janode/src/handle.js:246:19)
backend_1   |     at Session._handleMessage (file:///usr/src/server/node_modules/janode/src/session.js:264:14)
backend_1   |     at Connection._handleMessage (file:///usr/src/server/node_modules/janode/src/connection.js:200:17)
backend_1   |     at WebSocket.<anonymous> (file:///usr/src/server/node_modules/janode/src/transport-ws.js:166:26)
backend_1   |     at WebSocket.onMessage (/usr/src/server/node_modules/ws/lib/event-target.js:199:18)
backend_1   |     at WebSocket.emit (node:events:520:28)
backend_1   |     at Receiver.receiverOnMessage (/usr/src/server/node_modules/ws/lib/websocket.js:1137:20)
backend_1   |     at Receiver.emit (node:events:520:28)
backend_1   |     at Receiver.dataMessage (/usr/src/server/node_modules/ws/lib/receiver.js:528:14) {
backend_1   |   _code: 426
backend_1   | }
backend_1   | 2022-03-07T13:03:19.931Z - INFO : [janus.js] [172.20.0.8:58336] disconnected socket
backend_1   | 2022-03-07T13:03:19.933Z - ERROR: [transport-ws.js] [8999818924408386] websocket send error (WebSocket is not open: readyState 2 (CLOSING))
backend_1   | 2022-03-07T13:03:19.940Z - INFO : [transport-ws.js] [8999818924408386] websocket closed code=1005 reason= clean=true
backend_1   | 2022-03-07T13:03:19.940Z - INFO : [transport-ws.js] [8999818924408386] websocket ping task disabled
backend_1   | 2022-03-07T13:03:19.941Z - INFO : [tmanager.js] [8999818924408385] clearing transaction manager
backend_1   | 2022-03-07T13:03:19.941Z - INFO : Connection with Janus closed
atoppi commented 2 years ago

The videoroom plugin does not close the transport connection in case of errors. The connection.close() is probably coming from the application code.

For example in the videoroom example there is connection.close call in the catch block of the initialization. https://github.com/meetecho/janode/blob/master/examples/videoroom/src/index.js#L95-L97

alvitoraidhy commented 2 years ago

The videoroom plugin does not close the transport connection in case of errors. The connection.close() is probably coming from the application code.

For example in the videoroom example there is connection.close call in the catch block of the initialization. https://github.com/meetecho/janode/blob/master/examples/videoroom/src/index.js#L95-L97

Oh right thanks. I did use the example as the base, I should've looked at the code more thoroughly. I'll close this now