ssm-session-client icon indicating copy to clipboard operation
ssm-session-client copied to clipboard

Port forwarding session terminates by itself

Open djselzlein opened this issue 3 months ago • 1 comments

I have been using the ssmclient.PluginSession(cfg, tgt) method for establishing port forwarding, as suggested in the following example: https://github.com/mmmorris1975/ssm-session-client/blob/main/examples/port-forwarder/main.go#L59

However, the session terminates automatically after about 30s idle, there are example logs:

Starting session with SessionId: abc123
Port 9999 opened for sessionId abc123
Waiting for connections...


Exiting session with sessionId: abc123.

Is there some config that needs to be set for the session to last longer? I have experienced similar early termination when using this repo's implementation as well: https://github.com/mmmorris1975/ssm-session-client/blob/main/examples/port-forwarder/main.go#L60

This is a snippet of the code I'm running:

	in := ssmclient.PortForwardingInput{
		Target:     tgt,
		RemotePort: remotePort,
		LocalPort:  localPort, // just use random port for demo purposes (this is the default, if not set > 0)
	}

	log.Println("Starting port forwarding session!")
	log.Fatal(ssmclient.PortPluginSession(awsConfig, &in))
	log.Println("Port forwarding session finished!")

djselzlein avatar Nov 02 '24 19:11 djselzlein