File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -807,11 +807,16 @@ export class DirectLine implements IBotConnection {
807807 // WebSockets can be closed by the server or the browser. In the former case we need to
808808 // retrieve a new streamUrl. In the latter case we could first retry with the current streamUrl,
809809 // but it's simpler just to always fetch a new one.
810- . retryWhen ( error$ => error$ . delay ( 3000 ) . mergeMap ( error => this . reconnectToConversation ( ) ) )
810+ . retryWhen ( error$ => error$ . delay ( this . getRetryDelay ( ) ) . mergeMap ( error => this . reconnectToConversation ( ) ) )
811811 )
812812 . flatMap ( activityGroup => this . observableFromActivityGroup ( activityGroup ) )
813813 }
814814
815+ // Returns the delay duration in milliseconds
816+ private getRetryDelay ( ) {
817+ return Math . floor ( 3000 + Math . random ( ) * 12000 ) ;
818+ }
819+
815820 // Originally we used Observable.webSocket, but it's fairly opionated and I ended up writing
816821 // a lot of code to work around their implemention details. Since WebChat is meant to be a reference
817822 // implementation, I decided roll the below, where the logic is more purposeful. - @billba
You can’t perform that action at this time.
0 commit comments