File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ Server.prototype.close = function () {
191191 if ( this . ws ) {
192192 debug ( 'closing webSocketServer' ) ;
193193 this . ws . close ( ) ;
194- delete this . ws ;
194+ // don't delete this.ws because it can be used again if the http server starts listening again
195195 }
196196 return this ;
197197} ;
Original file line number Diff line number Diff line change @@ -543,6 +543,27 @@ describe('server', function () {
543543 } ) ;
544544 } ) ;
545545
546+ it ( 'should allow client reconnect after restarting (ws)' , function ( done ) {
547+ var opts = { transports : [ 'websocket' ] } ;
548+ var engine = listen ( opts , function ( port ) {
549+ engine . httpServer . close ( ) ;
550+ engine . httpServer . listen ( port ) ;
551+
552+ var socket = new eioc . Socket ( 'ws://localhost:%d' . s ( port ) , { transports : [ 'websocket' ] } ) ;
553+
554+ engine . once ( 'connection' , function ( conn ) {
555+ setTimeout ( function ( ) {
556+ conn . close ( ) ;
557+ } , 10 ) ;
558+ } ) ;
559+
560+ socket . once ( 'close' , function ( reason ) {
561+ expect ( reason ) . to . be ( 'transport close' ) ;
562+ done ( ) ;
563+ } ) ;
564+ } ) ;
565+ } ) ;
566+
546567 it ( 'should trigger when client closes' , function ( done ) {
547568 var engine = listen ( { allowUpgrades : false } , function ( port ) {
548569 var socket = new eioc . Socket ( 'ws://localhost:%d' . s ( port ) ) ;
You can’t perform that action at this time.
0 commit comments