Delayed disconnect after unPublishStream and WebSocket timeout handling in Flashphoner WCS

hyuk

Member
We are currently experiencing an issue with how disconnect events are handled in our WebRTC-based application using Flashphoner WCS.

The application was developed quite a long time ago, and unfortunately we no longer have a record of which WCS version was used during development.


In our current setup, the publisher calls `unPublishStream`, and the client expects to receive an `onDisconnection` event to trigger the UI cleanup for ending the broadcast.

However, during recent testing, we observed the following:

- The `unPublishStream` request is processed correctly.
- Approximately one minute later, the server logs show a message like:
`"Websocket ping/pong timeout us detected. Removing channel and disconnect client."`
- However, the client does not receive any `onDisconnection` event, so the UI does not update and the broadcast appears to remain active.


Questions:
1. Is there a way to **reduce the WebSocket ping/pong timeout duration**, so disconnects can be detected more quickly?
2. Have there been **any recent changes** in WCS versions regarding **default timeout behavior or WebSocket session handling**?
3. Is it considered **best practice to handle broadcast termination using the `onDisconnection` event** on the client side after calling `unPublishStream`, or is there a more reliable or recommended method?

Any guidance you can provide on this matter would be greatly appreciated.

Thank you for your support.

Best regards,
 
Last edited:
add )
keep_alive.server_interval=1000
keep_alive.probes=1 For now, I've done this, and the ping-pong time has passed, so the connection from the server is disconnected and re-established quickly, but it seems like the onDisconnection event is not being called.
When is onDisconnection called?
 
In our current setup, the publisher calls `unPublishStream`, and the client expects to receive an `onDisconnection` event to trigger the UI cleanup for ending the broadcast.

This is correct flow:

1. >> Flashphoner.createSession()
Websocket message: connection

2. << ConnectionStatusEvent.ESTABLISHED
Websocket message: getUserData

3. >> stream.publish()
Websocket message: publishStream

4. << StreamStatusEvent.PUBLISHING
Websocket message: notifyStreamStatusEvent

5. >> stream.stop() unPublishStream
Websocket message: unPublishStream

6. << StreamStatusEvent.UNPUBLISHED notifyStreamStatusEvent
Websocket message: notifyStreamStatusEvent

7. >> session.disconnect; //websocket disconnect
Websocket message: No (Just close a connection)

See also Developer Tools (Ctrl + Shift + I) - Network


Here you can see how looks all messages and events.

Code:


1745930182083.png
 
Top