@@ -318,6 +318,18 @@ Connection.prototype.accept = function (socket) {
318318 return this . init ( socket ) ;
319319} ;
320320
321+
322+ Connection . prototype . abort_socket = function ( socket ) {
323+ if ( socket === this . socket ) {
324+ log . io ( '[%s] aborting socket' , this . options . id ) ;
325+ this . socket . end ( ) ;
326+ this . socket . removeAllListeners ( 'data' ) ;
327+ this . socket . removeAllListeners ( 'error' ) ;
328+ this . socket . removeAllListeners ( 'end' ) ;
329+ this . _disconnected ( ) ;
330+ }
331+ } ;
332+
321333Connection . prototype . init = function ( socket ) {
322334 this . socket = socket ;
323335 if ( this . get_option ( 'tcp_no_delay' , false ) && this . socket . setNoDelay ) {
@@ -464,6 +476,9 @@ Connection.prototype.output = function () {
464476 } else if ( this . is_open ( ) && this . remote . open . idle_time_out ) {
465477 this . heartbeat_out = setTimeout ( this . _write_frame . bind ( this ) , this . remote . open . idle_time_out / 2 ) ;
466478 }
479+ if ( this . local . open . idle_time_out && this . heartbeat_in === undefined ) {
480+ this . heartbeat_in = setTimeout ( this . idle . bind ( this ) , this . local . open . idle_time_out ) ;
481+ }
467482 }
468483 } catch ( e ) {
469484 this . saved_error = e ;
@@ -527,10 +542,12 @@ Connection.prototype.input = function (buff) {
527542} ;
528543
529544Connection . prototype . idle = function ( ) {
530- if ( this . is_open ( ) ) {
545+ if ( ! this . is_closed ( ) ) {
531546 this . abort_idle = true ;
547+ this . closed_with_non_fatal_error = true ;
532548 this . local . close . error = { condition :'amqp:resource-limit-exceeded' , description :'max idle time exceeded' } ;
533549 this . close ( ) ;
550+ setTimeout ( this . abort_socket . bind ( this , this . socket ) , 1000 ) ;
534551 }
535552} ;
536553
@@ -549,7 +566,10 @@ Connection.prototype._disconnected = function (error) {
549566 clearTimeout ( this . heartbeat_out ) ;
550567 this . heartbeat_out = undefined ;
551568 }
552- if ( this . heartbeat_in ) clearTimeout ( this . heartbeat_in ) ;
569+ if ( this . heartbeat_in ) {
570+ clearTimeout ( this . heartbeat_in ) ;
571+ this . heartbeat_in = undefined ;
572+ }
553573 var was_closed_with_non_fatal_error = this . closed_with_non_fatal_error ;
554574 if ( this . closed_with_non_fatal_error ) {
555575 this . closed_with_non_fatal_error = false ;
0 commit comments