Skip to content

Commit 1685d65

Browse files
ckkashyapcompulim
authored andcommitted
Add a delay before retrying to connect to websocket. (#97)
* Add a delay before retrying to connect to websocket. A delay of 3 seconds is chosen so that we hit the server less frequently for the case where websocket connection is not going to succeed at all. At the same time it is not too long for the cases when a reconnect succeeds - it will be perceived as a transient glitch by the user since subsequent activities would show up in time. * Update CHANGELOG.md
1 parent 3f519c0 commit 1685d65

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Added
99
- Add support for watermark in Web Socket, in [#96](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/96)
1010

11+
### Changed
12+
- Delay before retrying Web Socket, in [#97](https://github.com/Microsoft/BotFramework-WebChat/pull/97)
13+
1114
## [0.9.17] - 2018-08-31
1215
### Changed
1316
- Add handling of 403/500 for `getSessionId`, in [#87](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/87)

src/directLine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ export class DirectLine implements IBotConnection {
646646
// WebSockets can be closed by the server or the browser. In the former case we need to
647647
// retrieve a new streamUrl. In the latter case we could first retry with the current streamUrl,
648648
// but it's simpler just to always fetch a new one.
649-
.retryWhen(error$ => error$.mergeMap(error => this.reconnectToConversation()))
649+
.retryWhen(error$ => error$.delay(3000).mergeMap(error => this.reconnectToConversation()))
650650
)
651651
.flatMap(activityGroup => this.observableFromActivityGroup(activityGroup))
652652
}

0 commit comments

Comments
 (0)