File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -76,13 +76,16 @@ Socket.prototype.onOpen = function () {
7676
7777Socket . prototype . onPacket = function ( packet ) {
7878 if ( 'open' == this . readyState ) {
79+ // Reset ping timeout on any packet, incoming data is a good sign of
80+ // other side's liveness
81+ this . setPingTimeout ( ) ;
82+
7983 switch ( packet . type ) {
8084
8185 case 'ping' :
8286 debug ( 'got ping' ) ;
8387 this . sendPacket ( 'pong' ) ;
8488 this . emit ( 'heartbeat' ) ;
85- this . setPingTimeout ( ) ;
8689 break ;
8790
8891 case 'error' :
Original file line number Diff line number Diff line change 66
77var http = require ( 'http' )
88 , parser = eio . parser
9- , WebSocket = require ( 'ws' )
10- , fs = require ( 'fs' ) ;
9+ , WebSocket = require ( 'ws' ) ;
1110
1211/**
1312 * Tests.
@@ -725,10 +724,15 @@ describe('server', function () {
725724 } ) ;
726725
727726 it ( 'should interleave with pongs if many messages buffered after connection open' , function ( done ) {
728- var opts = { transports : [ 'websocket' ] , pingInterval : 10 , pingTimeout : 5 } ;
727+ var opts = {
728+ transports : [ 'websocket' ] ,
729+ pingInterval : 200 ,
730+ pingTimeout : 100
731+ } ;
732+
729733 var engine = listen ( opts , function ( port ) {
730- var messageCount = 50 ;
731- var messagePayload = fs . readFileSync ( __filename ) ;
734+ var messageCount = 100 ;
735+ var messagePayload = new Array ( 1024 * 1024 * 1 ) . join ( 'a' ) ;
732736 var connection = null ;
733737 engine . on ( 'connection' , function ( conn ) {
734738 connection = conn ;
You can’t perform that action at this time.
0 commit comments