Opened 6 years ago

Closed 5 years ago

#1573 closed enhancement (fixed)

SAM no half-opened tcp connections detection

Reported by: z0rg1nc Owned by: zzz
Priority: minor Milestone: 0.9.24
Component: apps/SAM Version: 0.9.19
Keywords: Cc:
Parent Tickets: #1574 Sensitive: no


To reproduce: create SAM session from application in some VM, then power off or save VM. Such local tunnels stay alive forever, router restart required to drop them. The problem is - socket which only reads can't detect connection lost. We need some application-based 'ping' signal to check client status.
I propose to add optional parameter ping interval in seconds for 'create session' command to send 'PING' string to client every N seconds, if client doesn't answer 'PONG' withing timeout limit (or just IO exception from tcp), SAM closes tunnels and the tcp connection.


Change History (6)

comment:1 Changed 6 years ago by zzz

would setting the TCP keepalive option be sufficient? This would avoid a protocol change.

comment:2 Changed 6 years ago by zzz

BOB already sets keepalive.

Added to SAM and I2CP in 68de14d0053dea374413f9e0419b1c0f7e9ec3af i2p.i2p.zzz.sam to be propped for 0.9.21.

If this is not enough, changes will have to wait for SAM 3.2 #1574

comment:3 Changed 6 years ago by zzz

Milestone: undecided0.9.21
Owner: changed from mkvore to zzz
Status: newaccepted

comment:4 Changed 6 years ago by z0rg1nc

I'm not sure is tcp keepalive cross-platform (and is the option configures from server or client). Writing byte[0] every n seconds instead of both ping\pong and tcp keepalive looks better solution - it breaks nothing but works fine without protocol spec changing. However i'm not sure java actually send some packets on writing 0 length buffer, need to be tested.

It's not urgent - usually some datagrams will arrive within few minutes (for servers, clients can stuck forever i guess) and connection shuts down. But it's important for clients who are using ssh port forwarding\VMs.

Everything in the ticket is about repliable datagrams without UDP forwarding, one tcp connection to 7656 from client. Probably somebody should test streaming forwarding\etc too.

Last edited 6 years ago by z0rg1nc (previous) (diff)

comment:5 Changed 6 years ago by zzz

Parent Tickets: 1574

From my research, it is cross-platform (it's a part of the TCP spec) but it doesn't work in all situations. Both server and client should set it.

I doubt that byte[0] does anything. If it does, it's surely dependent on platform and buffering in the output stream pipeline.

I'll make this a subticket of #1574.

comment:6 Changed 5 years ago by zzz

Resolution: fixed
Status: acceptedclosed

PING/PONG in SAM v3.2 propped from i2p.i2p.zzz.sam to trunk in e9f846a5f270f31b374154729b12af8a379ecd79 0.9.23-3

Not going to do 0-length datagrams.

Note: See TracTickets for help on using tickets.