jerrington.me icon indicating copy to clipboard operation
jerrington.me copied to clipboard

Occasional “setsockopt TCP_NODELAY: Invalid argument” with “Roll your own Ngrok”

Open JetForMe opened this issue 1 year ago • 0 comments

Hey Jacob, thanks for the awesome and succinct post. I added -fNT to the ssh call to avoid the interactive session and put the process in the background.

It works well so far, but I get occasional output from ssh. They only occur sometimes when handling a request, never when it’s sitting idle (note, this is run without -f to keep its output visible):

% ssh -NT -R 3333:localhost:8080 my.host
setsockopt TCP_NODELAY: Invalid argument
setsockopt TCP_NODELAY: Invalid argument
setsockopt TCP_NODELAY: Invalid argument
setsockopt TCP_NODELAY: Invalid argument
setsockopt TCP_NODELAY: Invalid argument
setsockopt TCP_NODELAY: Invalid argument

One request with verbose logging:

debug3: receive packet: type 90
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 2 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 3333, originator 127.0.0.1 port 37732
debug1: connect_next: start for host localhost ([::1]:8080)
debug2: fd 8 setting O_NONBLOCK
debug2: fd 8 setting TCP_NODELAY
setsockopt TCP_NODELAY: Invalid argument
debug1: connect_next: connect host localhost ([::1]:8080) in progress, fd=8
debug3: fd 8 is O_NONBLOCK
debug3: fd 8 is O_NONBLOCK
debug1: channel 0: new forwarded-tcpip [127.0.0.1] (inactive timeout: 0)
debug1: confirm forwarded-tcpip
debug3: channel 0: waiting for connection
debug1: channel 0: connection failed: Connection refused
debug1: connect_next: start for host localhost ([127.0.0.1]:8080)
debug2: fd 9 setting O_NONBLOCK
debug2: fd 9 setting TCP_NODELAY
debug1: connect_next: connect host localhost ([127.0.0.1]:8080) in progress, fd=9
debug3: channel 0: waiting for connection
debug1: channel 0: connected to localhost port 8080
debug3: send packet: type 91
debug2: channel 0: read failed rfd 9 maxlen 32768: Broken pipe
debug2: channel 0: read failed
debug2: chan_shutdown_read: channel 0: (i0 o0 sock 9 wfd 9 efd -1 [closed])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i3 o1 sock 9 wfd 9 efd -1 [closed])
debug2: channel 0: output drain -> closed
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: 127.0.0.1, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 127.0.0.1 (t4 [forwarded-tcpip] r2 i3/0 o3/0 e[closed]/0 fd 9/9/-1 sock 9 cc -1 io 0x00/0x00)

Googling hasn’t turned up much. Any idea what might be causing this?

JetForMe avatar Mar 05 '24 11:03 JetForMe