confusing error with nntplib

E

Eduardo Alvarez

When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError

Running this a *second* time, gives me the following, different error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 258, in shortcmd
self.putcmd(line)
File "/usr/lib/python2.6/nntplib.py", line 198, in putcmd
self.putline(line)
File "/usr/lib/python2.6/nntplib.py", line 193, in putline
self.sock.sendall(line)
File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

As this is a broken pipe, I reconnect to the server, the same way as
before. When I *then* retrieving the newsgroup's info, I get no errors.

I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

yours,
 
A

Alf P. Steinbach

* Eduardo Alvarez, on 27.05.2010 03:01:
When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError

This sounds like a time-out.

Running this a *second* time, gives me the following, different error:

Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 258, in shortcmd
self.putcmd(line)
File "/usr/lib/python2.6/nntplib.py", line 198, in putcmd
self.putline(line)
File "/usr/lib/python2.6/nntplib.py", line 193, in putline
self.sock.sendall(line)
File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

When you say "running this", do you mean running a Python program a second time,
or issuing the same command in the interpreter a second time?

For the latter the result would be more or less expected.

After all, you've had an End of File on the connection.

As this is a broken pipe, I reconnect to the server, the same way as
before. When I *then* retrieving the newsgroup's info, I get no errors.

I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

Check if there's any way to specify time-outs.

Check if there's any way to trace the actual commands and responses.


Cheers & hth.,

- Alf
 
M

Martin P. Hellwig

When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError

Running this a *second* time, gives me the following, different error:

Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 258, in shortcmd
self.putcmd(line)
File "/usr/lib/python2.6/nntplib.py", line 198, in putcmd
self.putline(line)
File "/usr/lib/python2.6/nntplib.py", line 193, in putline
self.sock.sendall(line)
File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

As this is a broken pipe, I reconnect to the server, the same way as
before. When I *then* retrieving the newsgroup's info, I get no errors.

I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

yours,

Here is how I approached it:

# Lets see first if the server is available
[martin@aspire8930 /usr/home/martin]$ telnet nntp.aioe.org nntp
Trying 94.75.214.90...
Connected to nntp.aioe.org.
Escape character is '^]'.
200 nntp.aioe.org InterNetNews NNRP server INN 2.5.1 ready (posting ok)
^]
telnet> quit
Connection closed.
# Okidoki seems fine

# lets fire up python
[martin@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Apr 9 2010, 12:45:45)
[GCC 4.2.1 20070719 [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/local/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/local/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/local/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError
# Ah yes the same error, good at least the same problem.

# Lets see what the docs has to say about it.Help on class NNTP in module nntplib:

class NNTP
| # The class itself
|
| Methods defined here:
|
| __init__(self, host, port=119, user=None, password=None,
readermode=None, usenetrc=True)
| Initialize an instance. Arguments:
| - host: hostname to connect to
| - port: port to connect to (default the standard NNTP port)
| - user: username to authenticate with
| - password: password to use with username
| - readermode: if true, send 'mode reader' command after
| connecting.
|
| readermode is sometimes necessary if you are connecting to an
| NNTP server on the local machine and intend to call
| reader-specific comamnds, such as `group'. If you get
| unexpected NNTPPermanentErrors, you might need to set
| readermode.
|
# readermode seems to be worth a shot:('211 2444 50405 52862 comp.lang.python', '2444', '50405', '52862',
'comp.lang.python')# okidoki got something, but I have no idea why, perhaps need to have
# a look at the source to see what that mode actually does.
# But then again I think it would be better if you would do
# that and if you are feeling generous might contribute back
# to this thread what your findings where.
 
P

Peter Otten

Eduardo said:
When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError
I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

I tried your example and got the EOFError, too.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/nntplib.py", line 345, in group
resp = self.shortcmd('GROUP ' + name)
File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
return self.getresp()
File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
resp = self.getline()
File "/usr/lib/python2.6/nntplib.py", line 206, in getline
if not line: raise EOFError
EOFError('211 2445 50405 52863 comp.lang.python', '2445', '50405', '52863',
'comp.lang.python')

nntplib.NNTP(host, readermode=True) seems to fix the problem (if it wasn't
sheer luck).

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top