Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errno 104 on ssl socket handshake #1

Open
spaceone opened this issue Nov 10, 2016 · 0 comments
Open

Errno 104 on ssl socket handshake #1

spaceone opened this issue Nov 10, 2016 · 0 comments

Comments

@spaceone
Copy link
Owner

SocketError: <socket._socketobject object at 0x9b663ac>: [Errno 104] Connection reset by peer
ERROR  (<_read[http.server] (<socket._socketobject object at 0x93f325c> )>) (<class 'socket.error'>): error(104, 'Connection reset by peer')
Traceback (most recent call last):
  File "/home/spaceone/git/circuits/circuits/core/manager.py", line 815, in processTask
    value = next(task)
  File "/home/spaceone/git/circuits/circuits/net/sockets.py", line 623, in _accept
    for _ in do_handshake(sslsock, on_done, on_error, extra_args=(host,)):
  File "/home/spaceone/git/circuits/circuits/net/sockets.py", line 63, in do_handshake
    sock.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
    self._sslobj.do_handshake()
error: [Errno 104] Connection reset by peer

I found this merge conflict in my stashes, don't remember about it but maybe it helps/fix it:

diff --git a/circuits/net/sockets.py b/circuits/net/sockets.py
index 637df2e..bf9bafb 100644
--- a/circuits/net/sockets.py
+++ b/circuits/net/sockets.py
@@ -566,6 +566,7 @@ class Server(BaseComponent):
             self._poller.addWriter(self, sock)
         self._buffers[sock].append(data)
 
+<<<<<<< Updated upstream
     def _accept(self):  # noqa
         # XXX: C901: This has a high McCacbe complexity score of 10.
         # TODO: Refactor this!
@@ -582,6 +583,31 @@ class Server(BaseComponent):
 
         try:
             newsock, host = self._sock.accept()
+=======
+    def _accept(self):
+        newsock = None
+        try:
+            newsock, host = self._sock.accept()
+            if self.secure and HAS_SSL:
+                sslsock = ssl_socket(
+                    newsock,
+                    server_side=True,
+                    keyfile=self.keyfile,
+                    ca_certs=self.ca_certs,
+                    certfile=self.certfile,
+                    cert_reqs=self.cert_reqs,
+                    ssl_version=self.ssl_version,
+                    do_handshake_on_connect=False
+                )
+                try:
+                    _do_handshake_for_non_blocking(sslsock)
+                    newsock = sslsock
+                except SSLError as e:
+                    self.fire(error(newsock, e))
+                    newsock.shutdown(2)
+                    newsock.close()
+                    return
+>>>>>>> Stashed changes
         except SocketError as e:
             if e.args[0] in (EWOULDBLOCK, EAGAIN):
                 return
@@ -606,6 +632,11 @@ class Server(BaseComponent):
                 # _seems_ to be short-circuited by syncookies.
                 return
             else:
+                if newsock is not None:
+                    self.fire(error(newsock, e))
+                    newsock.shutdown(2)
+                    newsock.close()
+                    return
                 raise
 
         if self.secure and HAS_SSL:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant