Skip to content

Conversation

@compulim
Copy link
Collaborator

@compulim compulim commented Jul 11, 2023

Changelog

Added

  • Direct Line Streaming: Added networkInformation option to assist detection of connection issues, by @compulim, in PR #412

Designs

On iOS/iPadOS Safari, when connection change from Wi-Fi to cellular (say, walking away from coffee shop), the WebSocket object did not emit error event. It simply stalled. This only repros on iOS/iPadOS. It did not repro on Android Chrome.

To detect network type change, we could use networkInformation.type. However, Network Information API is not implemented in Safari.

We are adding a new option to allow web developers to provide a polyfill of W3C Network Information API. They could implement the polyfill using Server-Sent Events or native calls to NWPathMonitor.

When the NetworkInformation instance detected network change, it should:

  1. Change type to current network type, such as "cellular", "wifi", "unknown", or "none" (offline)
  2. Emit change event

Upon receiving the change event with type property changed, the chat adapter would terminate the current Web Socket connection and retries.

Currently, despite Network Information API is implemented in modern browsers, the type property may not be implemented. A simple polyfill for the type property:

Object.defineProperty(navigator.connection, 'type', {
  get() {
    return this.downlink ? 'unknown' : 'none';
  }
});

Specific changes

  • Added networkInformation to DirectLineStreaming options

@compulim compulim requested a review from a team as a code owner July 11, 2023 20:02
compulim and others added 2 commits July 11, 2023 13:39
Co-authored-by: TJ Durnford <[email protected]>
ckkashyap
ckkashyap previously approved these changes Jul 11, 2023
@compulim compulim merged commit d07e655 into microsoft:master Jul 11, 2023
@compulim compulim deleted the feat-add-watchdog-ase branch July 11, 2023 23:41
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.

4 participants