473,379 Members | 1,245 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,379 software developers and data experts.

TCP reset caused by socket.py

I've been working with the source code for Trac (http://
trac.edgewall.org/) lately and have run across a bizarre problem. It
seems that all POST requests to Trac's standalone server (tracd) have
a random chance of causing the server to issue a TCP RST packet that
resets the connection.

Running Trac 10.3.1 on Win2K3 using Python 2.4, watching traffic with
Wireshark 0.99.5.

I've been stepping through the code using Winpdb 1.3.2 and have
isolated the problem to the socket.py that's included in Python 2.4.
Line 157, in _socketobject.close():

self.send = self.recv = self.sendto = self.recvfrom =
self._sock._dummy

is what's causing the TCP RST to be issued. If I set a breakpoint on
that line and step over it on a POST request, there's about an 80%
chance the server will issue a TCP RST. When debugging, the entire
response makes it onto the wire before TCP RST is issued. If I'm -
not- debugging, it's anybody's guess as to how much of the response
makes it out. The interruption, when it occurs, always seems to be
between calls to _fileobject.write(). This indicates a timing issue:
perhaps buffered data isn't being waited on properly prior to
the .close() method doing its work.

I can't tell if this is a problem with the way Trac was coded (i.e.
are they violating the rules of sockets?) or whether it indicates a
problem in Python's socket implementation. Either way, isn't this a
strange statement (an assignment) for a TCP RST to occur? I can only
figure that the garbage collector is unpredictably disposing of a
socket at this opportunity. And why only for POST requests?

I'm looking for any insight anyone can provide about this!

--
Jeff S.
Dec 11 '07 #1
5 3697
Gabriel Genellina wrote:
A RST when you close a socket is OK.
Says who? MS? ;)

Regards,
Björn

--
BOFH excuse #328:

Fiber optics caused gas main leak

Dec 12 '07 #2
En Wed, 12 Dec 2007 15:46:14 -0300, Bjoern Schliessmann
<us**************************@spamgourmet.comescri bió:
Gabriel Genellina wrote:
>A RST when you close a socket is OK.
Says who? MS? ;)
Nevermind... just nonsense!

--
Gabriel Genellina

Dec 12 '07 #3
Is this applicable in your case?:http://brad.livejournal.com/2152593....2273#t10832273
(closing a nonblocking socket with a nonempty output queue generates a RST)
Based on my stepping through the code, everything passed to
_fileobject.write() makes it out onto the wire just fine. Now, if the
debugger isn't attached, like I said, it's anybody's guess how much
data gets out before the RST shows up. I need to delve deeper into
Trac's use of blocking vs. non-blocking sockets.
Indirectly: if the _sock attribute was the last reference to the real
socket object (and that's likely the case), assigning anything to _sock
will decrement its reference count to 0, then becoming a candidate for
garbage collection.

--
Gabriel Genellina
I don't know much about the timing of Python's garbage collection. Is
it pretty aggressive?

--
Jeff S.
Dec 12 '07 #4
Object01 wrote:
Is there something I can look for in the packet traffic that would
indicate one party is misbehaving? The sequence numbers seem ok.
*shrug* I'd expect to see data sent from server to client and
then see a sequence of packets that close the connection
gracefully. Instead I see the server send data to the client and
then a RST, nothing more.
I'm not sure, without any context. RSTs also seem to be used if a
TCP port is "closed", though from your description it seems that a
connection has been established when those RSTs come in.

Regards,
Björn

--
BOFH excuse #249:

Unfortunately we have run out of bits/bytes/whatever. Don't worry,
the next supply will be coming next week.

Dec 13 '07 #5
En Wed, 12 Dec 2007 20:12:43 -0300, Object01 <ob******@gmail.comescribi�:
I don't know much about the timing of Python's garbage collection. Is
it pretty aggressive?
As soon as the reference count reaches zero (at least for current CPython
version). Objects that are part of a reference cycle may take a while but
are detected and collected eventually.

--
Gabriel Genellina

Dec 13 '07 #6

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

Similar topics

4
by: Donnal Walter | last post by:
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,...
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)...
1
by: Bernd | last post by:
Hello, i have a problem with my network code. What i want to do is, send an UDP-packet and check if i get an icmp-reply type 3 (dest. unreachable). the code looks like that so far: .. ..
2
by: cyshao | last post by:
How to reset Router by programing? For some resean, we need usually reset our Router. Now, we have to Reset Router manually(shot down and reopen). Are there any method to control and reset...
6
by: Diego F. | last post by:
Hello. I'm writing an application that manages sockets and has a message protocol. I connect to another machine and I have to send and receive certain messages. I need the possibility to...
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...
53
by: Sanders Kaufman | last post by:
I'm having a BLAST writing this app as OOP as PHP allows. It's one thing to discuss the dance, but it's a thing of beauty to see the performance. I'm noticing that the constructor is a "reset"...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.