Know if tmate session have expired

695 views
Skip to first unread message

jav...@carnero.net

unread,
Jan 25, 2016, 6:41:41 AM1/25/16
to tmate.io
Hi everyone,

I've been working on a way to create a locked tmate session and send its ssh URL to a secure location when a remote computer starts up. At the moment I have it pretty much done, and I pretend to share it when it is finished. However I have a problem when I try to connect to a session that were created more than 24h before.

The message I have receiving is:
"Invalid or expired session token"

I understand this is happening because the tmate server is closing the session as it have been not used for several hours.

Is there an easy way, from this remote computer, to know if the session have expired and consequently create a new one?

Thanks.

Nicolas Viennot

unread,
Jan 25, 2016, 12:35:30 PM1/25/16
to jav...@carnero.net, tmate.io
Hi Javier,

I had to restart some servers recently, cutting all the opened connections. This was exceptional.
tmate should not drop sessions.
Further, the tmate client should support some reconnection feature at some point, to reconnect if the connection was dropped.
this is a little complicated, because 1) it might reconnect to a different server 2) all the terminal panes must be re-synced to some extent.
Sessions should not expire.

I don't think there's an easy way for telling if the session expired. But you can try:
$ curl https://tmate.io/api/t/SESSION_TOKEN
if the closed_at value is not null, the session has been closed for sure

This won't work in all cases (sessions are not expired on the database side just yet), but that might be a good start.

Nico


--
You received this message because you are subscribed to the Google Groups "tmate.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmate-io+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jav...@carnero.net

unread,
Jan 26, 2016, 6:42:54 AM1/26/16
to tmate.io, jav...@carnero.net
Hi Nico, this is what I'm getting from a yesterday (and expired) session when I use curl:

{"ws_url_fmt":"wss://am2.tmate.io/ws/session/%s","ssh_cmd_fmt":"ssh %s...@am2.tmate.io","created_at":"2016-01-25T18:40:04.138564Z","closed_at":"2016-01-25T23:08:51.170331Z"}

As you can see, the session closed five hours after being created. Any idea why is this happening?

Anyway I'm incorporating the "closed_at" check to my script, as it adds more reliability. Thanks.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages