@@ -58,9 +58,13 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
5858 . on ( 'error' , ( error ) => {
5959 if ( error . name === 'RangeError' && error . message === 'Max payload size exceeded' ) {
6060 console . error ( `web-socket-adapter: client ${ this . clientId } (${ this . getClientAddress ( ) } ) sent payload too large` )
61+ } else if ( error . name === 'RangeError' && error . message === 'Invalid WebSocket frame: RSV1 must be clear' ) {
62+ debug ( `client ${ this . clientId } (${ this . getClientAddress ( ) } ) enabled compression` )
6163 } else {
6264 console . error ( `web-socket-adapter: client error ${ this . clientId } (${ this . getClientAddress ( ) } ):` , error )
6365 }
66+
67+ this . client . close ( )
6468 } )
6569 . on ( 'message' , this . onClientMessage . bind ( this ) )
6670 . on ( 'close' , this . onClientClose . bind ( this ) )
@@ -125,9 +129,9 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
125129 }
126130
127131 public onHeartbeat ( ) : void {
128- if ( ! this . alive ) {
132+ if ( ! this . alive && ! this . subscriptions . size ) {
129133 console . error ( `web-socket-adapter: pong timeout for client ${ this . clientId } (${ this . getClientAddress ( ) } )` )
130- this . terminate ( )
134+ this . client . close ( )
131135 return
132136 }
133137
@@ -140,12 +144,6 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
140144 return new Map ( this . subscriptions )
141145 }
142146
143- private terminate ( ) : void {
144- debug ( 'terminating client %s' , this . clientId )
145- this . client . terminate ( )
146- debug ( 'client %s terminated' , this . clientId )
147- }
148-
149147 private async onClientMessage ( raw : Buffer ) {
150148 this . alive = true
151149 let abortable = false
0 commit comments