Skip to content

ec2-instance-connect logs me out after an hour with this message Websocket Closure Reason: Connection exceeded session timeout

0

How to increase the session timeout? Note that my session is not idle. it kicks me out of an active session where i am entering commands etc.

asked 13 days ago20 views
1 Answer
0

The issue you're experiencing with EC2 Instance Connect is related to the default session timeout. EC2 Instance Connect sessions typically last for one hour, after which you're automatically disconnected even if you're actively using the session.

Unfortunately, this one-hour session limit for EC2 Instance Connect is a fixed value and cannot be extended. This is different from the idle timeout that can be configured in some other AWS services.

To work around this limitation, you have a few options:

  1. Use a standard SSH client instead of EC2 Instance Connect. With a standard SSH client, you can configure keepalives to maintain your connection for longer periods.

  2. If you need to use EC2 Instance Connect, you'll need to reconnect after the one-hour timeout. You might want to consider setting up scripts or processes that can handle reconnection automatically.

  3. For longer sessions, consider using AWS Systems Manager Session Manager which may offer different timeout configurations.

If you're using a standard SSH client and experiencing disconnections, you can add the following to your SSH configuration:

ServerAliveInterval 59
ServerAliveCountMax 3

This will send a packet every 59 seconds to keep the connection alive and allow up to 3 missed responses before disconnecting.
Sources
EC2 ssh closes my connection, but not for others | AWS re:Post

answered 13 days ago
EXPERT
reviewed 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.