File tree 2 files changed +6
-17
lines changed 2 files changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -406,11 +406,11 @@ Resume the socket
406
406
- ` callback ` {Function} An optional callback which is invoked when ` data ` is
407
407
written out.
408
408
409
- Sends ` data ` through the connection.
409
+ Send ` data ` through the connection.
410
410
411
411
### websocket.terminate()
412
412
413
- Send a FIN packet to the other peer .
413
+ Forcibly close the connection .
414
414
415
415
### websocket.upgradeReq
416
416
Original file line number Diff line number Diff line change @@ -276,17 +276,16 @@ class WebSocket extends EventEmitter {
276
276
}
277
277
278
278
if ( this . readyState === WebSocket . CLOSING ) {
279
- if ( this . _closeCode ) this . terminate ( ) ;
279
+ if ( this . _closeCode && this . _socket ) this . _socket . end ( ) ;
280
280
return ;
281
281
}
282
282
283
283
this . readyState = WebSocket . CLOSING ;
284
284
this . _sender . close ( code , data , ! this . _isServer , ( err ) => {
285
285
if ( err ) this . emit ( 'error' , err ) ;
286
286
287
- if ( this . _closeCode ) {
288
- this . terminate ( ) ;
289
- } else {
287
+ if ( this . _socket ) {
288
+ if ( this . _closeCode ) this . _socket . end ( ) ;
290
289
//
291
290
// Ensure that the connection is cleaned up even when the closing
292
291
// handshake fails.
@@ -391,17 +390,7 @@ class WebSocket extends EventEmitter {
391
390
return ;
392
391
}
393
392
394
- if ( this . _socket ) {
395
- this . readyState = WebSocket . CLOSING ;
396
- this . _socket . end ( ) ;
397
-
398
- //
399
- // Add a timeout to ensure that the connection is completely cleaned up
400
- // within 30 seconds, even if the other peer does not send a FIN packet.
401
- //
402
- clearTimeout ( this . _closeTimer ) ;
403
- this . _closeTimer = setTimeout ( this . _finalize , closeTimeout , true ) ;
404
- }
393
+ this . finalize ( true ) ;
405
394
}
406
395
}
407
396
You can’t perform that action at this time.
0 commit comments