This repository was archived by the owner on Nov 23, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 180
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Fatal exception: ConnectionResetError #31
Copy link
Copy link
Closed
Description
Disclaimer: I don't know if you're interested in feedback on Tulip at this
point. If you aren't, just tell me, I'll stop bugging you until you release an
alpha :)
Context: I'm testing a WebSocket client running on Tulip against the AutoBahn
test suite (which runs on Twisted) on OS X.
Problem: I encounter the following error:
Fatal error for <tulip.selector_events._SelectorSocketTransport object at
0x10c0c1b50>
Traceback (most recent call last):
File "/Users/myk/Documents/dev/tulip/tulip/selector_events.py", line 336, in _read_ready
data = self._sock.recv(16*1024)
ConnectionResetError: [Errno 54] Connection reset by peer
Analysis:
`_SelectorSocketTransport._read_ready` expects `recv` to return an empty
bytestring when the end of the stream is reached. In this case, `recv` raises
an exception instead.
I could confirm that the connection is being closed in `KqueueSelector.select`,
because at that point `kev.flags` has the `KQ_EV_EOF` bit set. But that doesn't
appear to be the right place to handle this condition.
I think this problem has to do with the way the TCP connection is shut down. I
haven't managed to reproduce the problem with other servers. Still, it
shouldn't result in a fatal exception.
Reproduction:
Here's the simplest way to trigger the exception I have to offer — sorry :/
In a shell:
% mkvirtualenv --python=python2.7 autobahn
% pip install autobahntestsuite
% wstest -m fuzzingserver
In another shell:
% python3.3 dummy_client.py # see below
After a few seconds wstest times out, closes the connection and dummy_client.py
displays the stack trace.
------------------------------------------------------------------------
# dummy_client.py
import tulip
class DummyProtocol(tulip.Protocol):
def connection_made(self, transport):
self.transport = transport
self.stream = tulip.StreamReader()
def data_received(self, data):
self.stream.feed_data(data)
def eof_received(self):
self.stream.feed_eof()
self.transport.close()
loop = tulip.get_event_loop()
def main():
trans, proto = yield from loop.create_connection(
DummyProtocol, 'localhost', 9001)
yield from proto.stream.read()
loop.run_until_complete(main())
------------------------------------------------------------------------
Original issue reported on code.google.com by aymeric....@polytechnique.org
on 3 Apr 2013 at 5:41