ssm-session-client
ssm-session-client copied to clipboard
Port forwarding session terminates by itself
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!")