473,221 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

telnet 'connection reset by peer'

On Windows XP I am able to connect to a remote telnet server from the
command prompt using:

telnet nnn.nnn.nnn.nnn 23

where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows:

import telnetlib
host = 'nnn.nnn.nnn.nnn'
tn = telnetlib.Telnet(host, 23)
tn.read_until("Enter device name?")
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
4, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')

Is there some parameter that I need to set in order to connect using the
telnetlib client? Thanks.

Donnal Walter
Arkansas Children's Hospital
Jul 18 '05 #1
4 11060
Donnal Walter <do****@donnal.net> writes:
On Windows XP I am able to connect to a remote telnet server from the
command prompt using: telnet nnn.nnn.nnn.nnn 23 where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows: import telnetlib
host = 'nnn.nnn.nnn.nnn'
tn = telnetlib.Telnet(host, 23)
tn.read_until("Enter device name?")
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
4, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer') Is there some parameter that I need to set in order to connect using the
telnetlib client? Thanks.


No, that should work, to a reasonably conforming telnet server. Try doing
tn.set_debuglevel(2) before the read_until() to see what's coming back.

Does it happen instantly or is something timing out?

Eddie
Jul 18 '05 #2
Eddie Corns wrote:
Donnal Walter <do****@donnal.net> writes:

On Windows XP I am able to connect to a remote telnet server from the
command prompt using:
telnet nnn.nnn.nnn.nnn 23


where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows:


import telnetlib
host = 'nnn.nnn.nnn.nnn'
tn = telnetlib.Telnet(host, 23)
tn.read_until("Enter device name?")

Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
4, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')


Is there some parameter that I need to set in order to connect using the
telnetlib client? Thanks.

No, that should work, to a reasonably conforming telnet server. Try doing
tn.set_debuglevel(2) before the read_until() to see what's coming back.


Telnet(nnn.nn.nnn.nnn,23): recv
'\xff\xfb\x03\xff\xfd\x03\xff\xfb\x01\xff\xfd\x1
7\xff\xfb\x00\xff\xfd\x00'
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 3
Telnet(nnn.nn.nnn.nnn,23): IAC DO 3
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 1
Telnet(nnn.nn.nnn.nnn,23): IAC DO 23
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 0
Telnet(nnn.nn.nnn.nnn,23): IAC DO 0
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
5, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')

Thank you for the suggestion. Can you help me interpret the feedback?
Does it happen instantly or is something timing out?


No, it always happens instantly.

Thanks.

Donnal Walter
Arkansas Children's Hospital
Jul 18 '05 #3
Donnal Walter <do****@donnal.net> writes:
Eddie Corns wrote:
Donnal Walter <do****@donnal.net> writes:

On Windows XP I am able to connect to a remote telnet server from the
command prompt using:


telnet nnn.nnn.nnn.nnn 23


where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows:


import telnetlib
host = 'nnn.nnn.nnn.nnn'
tn = telnetlib.Telnet(host, 23)
tn.read_until("Enter device name?")

Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
4, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')


Is there some parameter that I need to set in order to connect using the
telnetlib client? Thanks.

No, that should work, to a reasonably conforming telnet server. Try doing
tn.set_debuglevel(2) before the read_until() to see what's coming back.

Telnet(nnn.nn.nnn.nnn,23): recv
'\xff\xfb\x03\xff\xfd\x03\xff\xfb\x01\xff\xfd\x 1
7\xff\xfb\x00\xff\xfd\x00'
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 3
Telnet(nnn.nn.nnn.nnn,23): IAC DO 3
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 1
Telnet(nnn.nn.nnn.nnn,23): IAC DO 23
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 0
Telnet(nnn.nn.nnn.nnn,23): IAC DO 0
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
5, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer') Thank you for the suggestion. Can you help me interpret the feedback?


The IACs are commands embedded in the data stream. This page:
http://www.scit.wlv.ac.uk/~jphb/comms/telnet.html looks like a decent overview
of how telnet works. The purpose here is to negotiate what the capabilities
of the telnet session (eg echo). Looking at the code in telnetlib, it seems
to always send back DONT or WONT for every option (ie refuses to support or
use any option requested). It's possible the server is deciding that on this
basis it cannot proceed. There doesn't seem to be a single place where all
the telnet options are described so I don't know what 0,1,3,23 actually are.
This page might help: http://home.swipnet.se/cfmd/rfc/dir/telnet.html
You might try using the tn.set_option_negotiation_callback() method to send
your own negotiation messages back if you think that what it is asking for is
harmless (you could snoop on your windows session, eg with ethereal, to see
what windows is sending back).

It seems a bit drastic to behave this way but I suppose it depends on what the
server is trying to do. I wouldn't rule out it being a completely different
problem but nothing springs to mind. It may be easier to experiment with
options using a raw socket, copy the code in telnetlib.

HTH,
Eddie
Jul 18 '05 #4
Eddie Corns wrote:
Donnal Walter <do****@donnal.net> writes:

Eddie Corns wrote:
Donnal Walter <do****@donnal.net> writes:

On Windows XP I am able to connect to a remote telnet server from the
command prompt using:
telnet nnn.nnn.nnn.nnn 23
where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows:
import telnetlib
host = 'nnn.nnn.nnn.nnn'
tn = telnetlib.Telnet(host, 23)
tn.read_until("Enter device name?")

Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
4, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')
Is there some parameter that I need to set in order to connect using the
telnetlib client? Thanks.
No, that should work, to a reasonably conforming telnet server. Try doing
tn.set_debuglevel(2) before the read_until() to see what's coming back.


Telnet(nnn.nn.nnn.nnn,23): recv
'\xff\xfb\x03\xff\xfd\x03\xff\xfb\x01\xff\xfd\ x1
7\xff\xfb\x00\xff\xfd\x00'
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 3
Telnet(nnn.nn.nnn.nnn,23): IAC DO 3
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 1
Telnet(nnn.nn.nnn.nnn,23): IAC DO 23
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 0
Telnet(nnn.nn.nnn.nnn,23): IAC DO 0
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line
5, in ?
tn.read_until("Enter device name?")
File "C:\Python23\lib\telnetlib.py", line 316, in read_until
self.fill_rawq()
File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
socket.error: (10054, 'Connection reset by peer')


Thank you for the suggestion. Can you help me interpret the feedback?

The IACs are commands embedded in the data stream. This page:
http://www.scit.wlv.ac.uk/~jphb/comms/telnet.html looks like a decent overview
of how telnet works. The purpose here is to negotiate what the capabilities
of the telnet session (eg echo). Looking at the code in telnetlib, it seems
to always send back DONT or WONT for every option (ie refuses to support or
use any option requested). It's possible the server is deciding that on this
basis it cannot proceed. There doesn't seem to be a single place where all
the telnet options are described so I don't know what 0,1,3,23 actually are.
This page might help: http://home.swipnet.se/cfmd/rfc/dir/telnet.html
You might try using the tn.set_option_negotiation_callback() method to send
your own negotiation messages back if you think that what it is asking for is
harmless (you could snoop on your windows session, eg with ethereal, to see
what windows is sending back).


Thank you. Dealing with telnet at this low level is all new to me, so
the urls and pointers were helpful. In particular, I downloaded ethereal
(also new to me) and filtered the packets by ip address. This way I
found that 0 is 'binary transmission', 1 is 'echo', 3 is 'suppress go
ahead' and 23 is 'send location' (plus I learned how to send location).
It seems a bit drastic to behave this way but I suppose it depends on what the
server is trying to do. I wouldn't rule out it being a completely different
problem but nothing springs to mind. It may be easier to experiment with
options using a raw socket, copy the code in telnetlib.


I still have not decided how I am going to tackle this. My first attempt
is likely to be an option_negotiation_callback function as you suggested
above. In any case, your suggestions have been most helpful. Thanks, again.

Donnal Walter
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mirandacascade | last post by:
This may be more of a socket question than a python question; not sure. Using this code to instantiate/connect/set options connectionHandle = socket.socket(socket.AF_INET, socket.SOCK_STREAM)...
7
by: Rex Winn | last post by:
I've Googled until my eyes hurt looking for a way to issue Telnet commands from C# and cannot find anything but $300 libraries that encapsulate it for you. I don't want to be able to create a...
4
by: Joe Lester | last post by:
I'm seeing this message a couple times per day in my postgres log: 2004-04-20 14:47:46 LOG: could not receive data from client: Connection reset by peer What does it mean? I've seen in the...
3
by: Van_Gogh | last post by:
Hi, I am learning how to use the smtplib module, but am having some very early problems, maybe because I don't understand it. So, am I correct that by following the example in the Python: >>>...
0
by: xristoph | last post by:
Hello everyone! I am trying to set up a broker-worker system (one broker, multiple and heterogeneous workers) in python for a local network (though possibly also over inet). I am using...
14
by: ahlongxp | last post by:
Hi, everyone, I'm implementing a simple client/server protocol. Now I've got a situation: client will send server command,header paires and optionally body. server checks headers and decides...
1
by: sreejithp | last post by:
Hello, I am new to python. I have been trying to connect to telnet and feed some data from a server. Its working properly. I used the connectionObj.read_until() method to read the data from the...
5
by: chrispoliquin | last post by:
Hi, I have a small Python script to fetch some pages from the internet. There are a lot of pages and I am looping through them and then downloading the page using urlretrieve() in the urllib...
2
by: gigs | last post by:
I connect to web site with httplib.HTTPConnection. after some time i get this error: 104 "connection reset by peer". What exception i should use to catche this error thx!
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.