EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SSH Tunnel Inactivity

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
Posted: 10/31/2011 03:40:57
by jiins (Standard support level)
Joined: 06/27/2011
Posts: 14

How to detect the TElSSHLocalPortForwarding tunnel idle time? Or put into other words, how to detect if it's still being used (to tunnel http traffic)?

Posted: 10/31/2011 03:54:35
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

You can track the number of opened tunnels. If its equal to zero then the TElSSHLocalPortForwarding is not used. This can be done using TElSSHCustomForwarding.TunnelCount property or TElSSHCustomForwarding.OnTunnelOpen/OnTunnelClose events.
Posted: 10/31/2011 04:22:03
by jiins (Standard support level)
Joined: 06/27/2011
Posts: 14

Thanks. But it seems that TunnelCount remains to 1 for some time after the tunnel has been established, even if there no http requests are made at all. It's been a few minutes now and it's still showing 1. Any ideas?
Posted: 10/31/2011 04:39:25
by Vsevolod Ievgiienko (Team)

Sorry for a wrong information. You should better use OnConnectionOpen and OnConnectionClose events to track connection opens and closures. This way, the number of active forwarded TCP connections will be equal to the difference between the number of opens and closures and when its equal to zero then TElSSHLocalPortForwarding is not used.
Posted: 10/31/2011 06:06:31
by jiins (Standard support level)
Joined: 06/27/2011
Posts: 14

Thanks, makes sense. But I notice that for example FireFox keeps between 1 and 5 connections open even when idle. Is there anything else that I could use?

Posted: 10/31/2011 06:18:24
by Vsevolod Ievgiienko (Team)

You are right. Firefox keeps a few permanent connections. For an instance, the latest version is always connected to Google. I think all you can do is disable some Firefox plugins.
Posted: 10/31/2011 06:28:11
by Ken Ivanov (Team)

First of all, it will make sense to raise the right question - what exactly do you need to track? Even if some connection is in idle state (e.g. that very same Firefox's ones), it is still alive and can be used for tunneling traffic in future, and terminating it might make little sense from the point of view of application-layer protocols.

If you only need to track such "pauses" in client-server communications, please have a look at the OnConnectionChange event. It is fired every time the state of a tunneled connection changes, in particular if some data has been tunneled through.
Posted: 10/31/2011 07:18:52
by jiins (Standard support level)
Joined: 06/27/2011
Posts: 14

I need to detect idle tunnels in order to close them. Since every ssh connection has a cost on the destination server, I need to keep the number to the minimum.
Posted: 10/31/2011 08:12:43
by Ken Ivanov (Team)

Handling OnConnectionWork event and checking the values of ReceivedFromSocket, SentToSocket, ReceivedFromChannel and SentToChannel properties from inside of the handler would be the right method for you then.
Posted: 11/01/2011 03:40:50
by jiins (Standard support level)
Joined: 06/27/2011
Posts: 14

Thanks. I can't find any info on the properties of SBSSHForwarding.TElSSHForwardedConnection. Can you please point me to the right place?
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.



Topic viewed 2167 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!