SSMAgentエラーメッセージ「Reach the retry limit 5 for receive messages. Error: websocket: close 1006 (abnormal closure): unexpected EOF」の対応について

2024.02.14

困っていた内容

SSMAgentからのログで以下のようなエラーメッセージが出力されております。
EC2の挙動に影響があるか&対応要否を教えてください。

ERROR [MessageGatewayService] Reach the retry limit 5 for receive messages. Error: websocket: close 1006 (abnormal closure): unexpected EOF"

どうすればいいの?

発生原因について

Amazon Systems Manager が提供する Session Manager ではWebSocket [1] を使用して、 EC2インスタンス上の SSMAgent サービスと Session Manager エンドポイント間に管理用の接続を確立いたします。
同管理接続は様々な要因で接続が切断される場合があり、この際上記のエラーが記録される実装となっております([2])。仮に Session Manager を使用していない場合でも、管理用の接続自体は確立されるため、切断のタイミングでエラーが記録されます。

対応について

SSM エージェントは管理接続が切断された場合に自動的に再接続を行う仕組みが組み込まれておりますので、Session Managerの動作には影響はありません。 Session Manager エンドポイントと SSM Agent 間の管理用の接続が切断された際に発生するエラーですので、特段の対処は不要です。
StartSession

Initiates a connection to a target (for example, a managed node) for a Session Manager session. Returns a URL and token that can be used to open a WebSocket connection for sending input and receiving outputs.

参考資料

[1]WebSocket
[2]amazon-ssm-agent/agent/session/communicator/websocketchannel.go