Checking for wrtc-transport disconnect on server side.


I have a wrtc transport on the server side, and it is connected to the transport on the client side. Upon the user disconnecting, whether that’d be closing the tab or what not, I need to do some clean up on the server side.

I tried to use the “connectionstatechange” event, but the even never seems to get hit, not even once, despite being able to receive video and audio transmitted from server side to client side.

Could somebody point me in the right direction?


const recvTransport = await soup.router.createWebRtcTransport({
        listenIps: [{ ip: room.ip, announcedIp: null }],
        enableUdp: true,
        enableTcp: true,
        preferUdp: true,
        enableSctp: true,

recvTransport.on("connectionstatechange", connectionState => {

You are looking for“close”, fn()) event.

This assumes that the app called transport.close() in server side and I’m not sure about that.

It looks something you need to do upon WebSocket disconnection or by user disconnection means, at application level, rather than at WebRTC level.

Thank you both for the speedy replies!