Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
telnetlib timeout
#1
Hi,

I made this test script, to connect to a telnet server, it works, if there is data to read, but if nor or the server is not available the script never jumps to the exception. It looks to me that the timeout parameter does not have any effect.
I experimented with the EOFError that read_until method raises according to the telnetlib documentation as well, without success.

while True:
    try:
        print('connecting')
        c = telnetlib.Telnet(ip, port, timeout=1)
        print('reading')
        message = str(c.read_until(b'BBB'))
        print(message.strip('b'))
        connection.close()
    except Exception as e:
        print(e)
        time.sleep(5)
        pass
Any idea, please?

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Telnetlib reading output petterg 2 14,173 Sep-16-2024, 02:46 PM
Last Post: pypa
  telnetlib. configure hostnames lado 1 3,623 May-30-2020, 01:49 PM
Last Post: matya0403
  Python Pexpect - SSH Timeout Nirmal 3 8,139 Oct-17-2018, 02:35 PM
Last Post: wavic
  Python script hangs after entering username to remote login using telnetlib auto 0 5,520 Sep-10-2018, 01:10 PM
Last Post: auto
  telnetlib timeout expections handling issue anna 0 8,634 Jun-08-2018, 06:28 AM
Last Post: anna
  Set request timeout for socketserver voltron 0 5,190 May-24-2018, 06:17 AM
Last Post: voltron
  python telnetlib prompt matching issue anna 0 4,539 Jan-30-2018, 05:34 PM
Last Post: anna
  telnetlib.Telnet timeout issue.. taking much time anna 1 9,336 Jan-19-2018, 01:52 PM
Last Post: devs4p
  how to deal with easysnmp timeout anna 0 4,343 Dec-27-2017, 12:10 PM
Last Post: anna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020