Leese310
Leese310

Reputation: 11

Telnet closes by foreign host during scripts running

I telnet to a windows machine from a Linux server to run a python script. The script will keep running about 25mins while it always exits after about 20mins running because the Telnet is closed. It shows "connection closed by foreign host" on Linux server.

Is there any way to keep the session open during the script running?

Telnet configuration on windows:

The following are the settings on localhost

Alt Key Mapped to 'CTRL+A'  :   YES
Idle session timeout        :   Not On
Max connections             :   10
Telnet port                 :   23
Max failed login attempts   :   3
End tasks on disconnect     :   YES
Mode of Operation           :   Console
Authentication Mechanism    :   NTLM, Password
Default Domain              :   NGAI_Veriwave
State                       :   Running

Upvotes: 1

Views: 1272

Answers (2)

Bob77
Bob77

Reputation: 13267

Most likely the Telnet service has IdleSessionTimeout enabled (timeoutactive=yes).

I doubt it has anything at all to do with TCP KeepAlives.

Upvotes: 0

Patrick Maupin
Patrick Maupin

Reputation: 8137

What you need is to enable keepalives on your telnet session. If you are doing it from the Python side, you typically do:

x = sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

I'm not sure if that works when the Python is the host, though -- you should look to see if your telnet program (e.g. putty) has that option as well. Here is a bit more information on the topic.

Upvotes: 0

Related Questions