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. configure hostnames lado 1 2,879 May-30-2020, 01:49 PM
Last Post: matya0403
  Telnetlib reading output petterg 1 11,189 Jul-06-2019, 12:08 PM
Last Post: searching1
  Python script hangs after entering username to remote login using telnetlib auto 0 4,779 Sep-10-2018, 01:10 PM
Last Post: auto
  telnetlib timeout expections handling issue anna 0 7,753 Jun-08-2018, 06:28 AM
Last Post: anna
  python telnetlib prompt matching issue anna 0 3,956 Jan-30-2018, 05:34 PM
Last Post: anna
  telnetlib.Telnet timeout issue.. taking much time anna 1 8,195 Jan-19-2018, 01:52 PM
Last Post: devs4p

Forum Jump:

User Panel Messages

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