Skip to content
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
7 changes: 6 additions & 1 deletion src/directLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,16 @@ export class DirectLine implements IBotConnection {
// WebSockets can be closed by the server or the browser. In the former case we need to
// retrieve a new streamUrl. In the latter case we could first retry with the current streamUrl,
// but it's simpler just to always fetch a new one.
.retryWhen(error$ => error$.delay(3000).mergeMap(error => this.reconnectToConversation()))
.retryWhen(error$ => error$.delay(this.getRetryDelay()).mergeMap(error => this.reconnectToConversation()))
)
.flatMap(activityGroup => this.observableFromActivityGroup(activityGroup))
}

// Returns the delay duration in milliseconds
private getRetryDelay() {
return Math.floor(3000 + Math.random() * 12000);
}

// Originally we used Observable.webSocket, but it's fairly opionated and I ended up writing
// a lot of code to work around their implemention details. Since WebChat is meant to be a reference
// implementation, I decided roll the below, where the logic is more purposeful. - @billba
Expand Down