@@ -678,6 +678,9 @@ class WebSocketConnection {
678
678
if ( this . config . keepAliveIntervalTime != null ) {
679
679
this . startKeepAliveIntervalTimer ( this . config . keepAliveIntervalTime ) ;
680
680
}
681
+ if ( this . config . keepAliveTimeoutTime != null ) {
682
+ this . setKeepAliveTimeoutTimer ( ) ;
683
+ }
681
684
682
685
this . logger . info ( `Started ${ this . constructor . name } ` ) ;
683
686
}
@@ -788,6 +791,7 @@ class WebSocketConnection {
788
791
} = { } ) {
789
792
this . logger . info ( `Stop ${ this . constructor . name } ` ) ;
790
793
this . stopKeepAliveIntervalTimer ( ) ;
794
+ this . stopKeepAliveTimeoutTimer ( ) ;
791
795
if (
792
796
this . socket . readyState !== ws . CLOSING &&
793
797
this . socket . readyState !== ws . CLOSED
@@ -837,7 +841,6 @@ class WebSocketConnection {
837
841
this . socket . off ( 'ping' , this . handleSocketPing ) ;
838
842
this . socket . off ( 'pong' , this . handleSocketPong ) ;
839
843
this . socket . off ( 'error' , this . handleSocketError ) ;
840
- this . stopKeepAliveTimeoutTimer ( ) ;
841
844
842
845
this . logger . info ( `Stopped ${ this . constructor . name } ` ) ;
843
846
}
@@ -866,6 +869,7 @@ class WebSocketConnection {
866
869
this . keepAliveTimeOutTimer . reset ( timeout ) ;
867
870
} else {
868
871
logger . debug ( `timeout created with delay ${ timeout } ` ) ;
872
+ this . keepAliveTimeOutTimer ?. cancel ( ) ;
869
873
this . keepAliveTimeOutTimer = new Timer ( {
870
874
delay : timeout ,
871
875
handler : keepAliveTimeOutHandler ,
@@ -877,7 +881,7 @@ class WebSocketConnection {
877
881
* Stops the keep alive interval timer
878
882
*/
879
883
protected stopKeepAliveTimeoutTimer ( ) : void {
880
- this . keepAliveIntervalTimer ?. cancel ( ) ;
884
+ this . keepAliveTimeOutTimer ?. cancel ( ) ;
881
885
}
882
886
883
887
protected startKeepAliveIntervalTimer ( ms : number ) : void {
0 commit comments