Nomad alloc exec disconnection and re-attachment to session


While connected to an alloc using the alloc exec command, we sometimes loose connection and see this error message -
failed to exec into task: websocket closed before receiving exit code: websocket: close 1000 (normal)
This disrupts the workflow. The allocations are still alive and running, but there is no way to reconnect to the same session to resume the work, or to check if the scripts ran to completion.

In short I am after the Nomad version of the kubernetes attach command
kubectl attach test-pod

Any recommended way to achieving this?


Hi @vikas.saroha,

Could you share a bit more details on this issue? Are you interacting with the Nomad API via a LoadBalancer of any kind or hitting the agent directly?

How long does it usually take to throw this error once you are inside an exec session?

Thanks for your reply @Ranjandas .

We are Interacting through an Application Load Balancer on AWS.

The timing is really random. Sometimes as soon as a 1-2 minutes of the sessions starting. Other times there are no issues even for hours.


Also do you know if there’s a way to re-connect with an existing exec session. Kubernetes allows that via the attach command