@@ -824,6 +824,7 @@ export default function (rootDir, listen, config, onConfigUpdate) {
824
824
825
825
var toRemoteApp = ( ep , provider , app , isDedicated , connectOptions ) => pipeline ( $ => $
826
826
. onStart ( ( ) => {
827
+ $lastDataTime = { }
827
828
$selectedEp = ep
828
829
return selectHub ( ep ) . then ( hub => {
829
830
$selectedHub = hub
@@ -832,7 +833,7 @@ export default function (rootDir, listen, config, onConfigUpdate) {
832
833
} )
833
834
. pipe ( ( ) => $selectedHub ? 'proxy' : 'deny' , {
834
835
'proxy' : ( $ => $
835
- . handleData ( ( ) => { $lastReceivedTime = Date . now ( ) } )
836
+ . handleData ( ( ) => { $lastDataTime . value = Date . now ( ) } )
836
837
. connectHTTPTunnel ( ( ) => {
837
838
var q = `?src=${ config . agent . id } `
838
839
if ( isDedicated ) q += '&dedicated'
@@ -846,11 +847,12 @@ export default function (rootDir, listen, config, onConfigUpdate) {
846
847
ping : ( ) => new Timeout ( 10 ) . wait ( ) . then ( new Data ) ,
847
848
} ) . to ( $ => $
848
849
. connectTLS ( tlsOptions ) . to ( $ => $
849
- . insert ( ( ) => checkTimeout ( ) )
850
+ // .insert(() => checkTimeout()) // TODO: Enable session timeout
850
851
. connect ( ( ) => $selectedHub , connectOptions )
851
852
)
852
853
)
853
854
)
855
+ . handleData ( ( ) => { $lastDataTime . value = Date . now ( ) } )
854
856
) ,
855
857
'deny' : ( $ => $
856
858
. onStart ( ( ) => logError ( `No route to endpoint ${ ep } ` ) )
@@ -859,10 +861,10 @@ export default function (rootDir, listen, config, onConfigUpdate) {
859
861
} )
860
862
)
861
863
862
- var $lastReceivedTime = 0
864
+ var $lastDataTime = null
863
865
864
866
function checkTimeout ( ) {
865
- if ( Date . now ( ) - $lastReceivedTime > 60000 ) {
867
+ if ( Date . now ( ) - $lastDataTime . value > 60000 ) {
866
868
return new StreamEnd
867
869
} else {
868
870
return new Timeout ( 10 ) . wait ( ) . then ( checkTimeout )
0 commit comments