Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle websocket errors #171

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/directLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,12 @@ export class DirectLine implements IBotConnection {

ws.onmessage = message => message.data && subscriber.next(JSON.parse(message.data));

ws.onerror = error => {
konsole.log("WebSocket error", error);
if (sub) sub.unsubscribe();
subscriber.error(error);
}

// This is the 'unsubscribe' method, which is called when this observable is disposed.
// When the WebSocket closes itself, we throw an error, and this function is eventually called.
// When the observable is closed first (e.g. when tearing down a WebChat instance) then
Expand Down