Skip to content

Conversation

disa6302
Copy link
Contributor

Issue #, if available:

What has changed?

  • Included ICE restart and SDP exchange in case of signaling disconnects.

Why was it changed?

  • To advertise ICE restart in samples and include support for signals application could use to allow SDP negotiation post a signaling close event (network disruption/network change)

How was it changed?

  • Included a new option in the test page to allow for ICE restart in case a disconnection or ICE agent failure is detected. The ICE restart is tried 3 times with the frequency controlled by messageTtl. In case of failure, we do not retry again. The option is not enabled by default and is controlled via a checkbox in the test page.
  • Included a new option in the test page to allow for signaling reconnect in case the WS closes. SDP exchange post signaling reconnect is tried 3 times the frequency of which is controlled by messageTtl. The option is not enabled by default and is controlled via a checkbox in the test page.
  • The WS reconnect attempt is configurable by the application. the default is set to 3. If WS reconnection succeeds, the signaling library emits an event for the application to handle offer/answer exchange.

Testing

  • Master: C SDK, Viewer: JS SDK on Chrome

    • Modified the C SDK sample to ensure no valid candidate pairs are formed to trigger an ICE restart and succeed post restart
    • Disconnected ethernet and reconnected to ensure ICE restart allows communication to continue
    • Disconnected ethernet to allow connection via WiFi to test out signaling reconnect. ICE restart does not help here since the websocket on the other peer is closed but the SDP offer is supposedly successfully sent.
  • Master: C SDK, Viewer: JS SDK on Firefox

    • Firefox does not work with reconnection. The issue is on DTLS where, firefox does not seem to work if the remote generates a new fingerprint.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

* connection has been closed.
*/
public close(): void {
console.log("Closing the websocket");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the logging configurable? Currently there is no logs so adding logs might be something customers want to disable

this.open();
// If reconnect fails
setTimeout(() => {
if (this.readyState !== ReadyState.OPEN) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic needed to check if close was already called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTimeout returns a timer id, you can use clearTimeout(id) in close to stop the pending countdown as well

setTimeout(() => {
if (this.readyState !== ReadyState.OPEN) {
if (attempt < maxAttempts) {
console.log("Failed reconnect attempt ", attempt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                    console.log("Failed reconnect attempt ", attempt);
Suggested change
console.log("Failed reconnect attempt ", attempt);
console.log("Failed reconnect attempt", attempt);

Space not needed, this will result in double space

}
}, this.reconnectDelay * (attempt + 1)); // increasing delay
} else {
console.log('Invalid state to invoke reconnect from');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also log that invalid state - this.readyState

default:
console.log("No reconnect will be attempted. Just exiting with code", event.code);
this.cleanupWebSocket();
this.emit('close');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also emit the event as data? Then someone can take this data and take action

Suggested change
this.emit('close');
this.emit('close', event);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants