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

Web: catch OSError crash #88

Closed
wants to merge 1 commit into from
Closed

Web: catch OSError crash #88

wants to merge 1 commit into from

Conversation

treemo
Copy link
Contributor

@treemo treemo commented Jun 9, 2015

2015-06-09 17:16:09 CRITICAL ERROR <handler[*][read] (HTTP._on_read)> (<read[web] (<ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=2049, proto=0>, b'POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: close\r\nContent-Length: 4\r\nUser-Agent: Python-urllib/3.4\r\nHost: example.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nlog=test' )>) (<class 'OSError'>): OSError(9, 'Bad file descriptor') File "circuits/circuits/core/manager.py", line 668, in _dispatcher
value = event_handler(_eargs, *_ekwargs)
File "circuits/circuits/web/http.py", line 270, in _on_read
headers=parser.get_headers(), server=self._server
File "circuits/circuits/web/wrappers.py", line 186, in init
name = sock.getsockname()

2015-06-09 17:16:09 CRITICAL ERROR <handler[*][read] (HTTP._on_read)> (<read[web] (<ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=2049, proto=0>, b'POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: close\r\nContent-Length: 4\r\nUser-Agent: Python-urllib/3.4\r\nHost: example.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nlog=test' )>) (<class 'OSError'>): OSError(9, 'Bad file descriptor')  File "circuits/circuits/core/manager.py", line 668, in _dispatcher
    value = event_handler(*eargs, **ekwargs)
  File "circuits/circuits/web/http.py", line 270, in _on_read
    headers=parser.get_headers(), server=self._server
  File "circuits/circuits/web/wrappers.py", line 186, in __init__
    name = sock.getsockname()
@treemo treemo closed this Jun 9, 2015
@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 7ce3aab on treemo:master into 16d52a1 on circuits:master.

@prologic
Copy link
Member

Erroneous patch? :)

@treemo
Copy link
Contributor Author

treemo commented Jun 10, 2015

this patch does not resolve the source of the problem (multiple OSError appears in circuits, when web ssl are used) ^^

@prologic
Copy link
Member

Ahh got a traceback and something to report as an issue?

@treemo
Copy link
Contributor Author

treemo commented Jun 10, 2015

OsError appear random (one part of the web requests working properly):

2015-06-09 17:16:09 CRITICAL ERROR (, b'POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: close\r\nContent-Length: 4\r\nUser-Agent: Python-urllib/3.4\r\nHost: example.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nlog=test' )>) (): OSError(9, 'Bad file descriptor') File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/circuits/core/manager.py", line 668, in dispatcher
value = event_handler(eargs, *ekwargs)
  File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/circuits/web/http.py", line 270, in on_read
    headers=parser.get_headers(), server=self._server
  File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/circuits/web/wrappers.py", line 186, in __init
    name = sock.getsockname()
2015-06-09 19:09:14 CRITICAL ERROR <handler[*][_read][1.00] (TCPServer._on_read)> (<_read[web] (<socket.socket fd=4, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('0.0.0.0', 443)> )>) (<class 'OSError'>): OSError(9, 'Bad file descriptor')  File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/core/manager.py", line 668, in _dispatcher
    value = event_handler(*eargs, **ekwargs)
  File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/net/sockets.py", line 584, in _on_read
    self._accept()
  File "/usr/local/lib/python3.4/dist-packages/circuits-dev-py3.4.egg/circuits/net/sockets.py", line 541, in _accept
    newsock.shutdown(2)

@prologic
Copy link
Member

Hmm is this a case of the peer has shutdown it's end mid-way through the request/response?

@treemo
Copy link
Contributor Author

treemo commented Jun 10, 2015

that's what I suspect

@treemo
Copy link
Contributor Author

treemo commented Jun 10, 2015

when reverse proxy used: it work

INTERNET <=> circuit (web with ssl): OsError appear random
INTERNET <=> nginx (with ssl) <=> circuit (web without ssl): it work

@prologic
Copy link
Member

Ahh interesting :)

@spaceone
Copy link
Contributor

I don't quite understand when this happens. Can you explain it to me?
Well, socket.getsockname() may raise if the socket is not anymore connected.
Does it have to do with the reverse proxy you are using?

@treemo
Copy link
Contributor Author

treemo commented Jun 12, 2015

@spaceone this error appear randomly (source unknown)
the socket are apparently closed (I don't know why) only if SSL is used on Web server
the reverse proxy fix this issue (apparently the problem is in the Web SSL server)

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

Successfully merging this pull request may close these issues.

None yet

4 participants