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

evenlet monkey patching got error "WantReadError" #189

Open
Neetuj opened this issue Jan 12, 2015 · 3 comments

Comments

@Neetuj
Copy link

commented Jan 12, 2015

I am using apnse_client for sending puch notifications which uses pyopenssl

https://bitbucket.org/sardarnl/apns-client/src/48f7115722e0fdcc12cd6f7263b55fd1f40409b2?at=default

I can see that evenlet supports pyopnessl http://eventlet.net/doc/ssl.html#pyopenssl
Now i was assuming when i monkeypatch my whole project ( which has many other libraries also which works with monkey patch) ..apns will also work with it but instead i get this error:-

WARNING:apns_clerk.backends.stdio:Failed to establish socket/SSL connection to ('gateway.sandbox.push.apple.com', 2195) 
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/apns_clerk/backends/stdio.py", line 168, in _open_connection self._connect_and_handshake()
File "build/bdist.linux-x86_64/egg/apns_clerk/backends/stdio.py", line 205, in _connect_and_handshake self._connection.do_handshake() 
WantReadError

any pointers ??

@temoto

This comment has been minimized.

Copy link
Member

commented Jan 17, 2015

Please provide more information to debug your problem:

python -V
python -c 'import eventlet; print(eventlet.__version__)'

URL to which you are trying to connect or minimal code to reproduce it.

Try to update to latest eventlet v0.16.1, there was a bug fix related to Python 2.7.9.

@MarSoft

This comment has been minimized.

Copy link

commented Sep 1, 2015

Same problem here.

$ python -V
Python 3.4.3
$ python -c 'import eventlet; print(eventlet.__version__)'
0.17.4

Traceback:

[2015-09-01 15:45:15,391] [main] [ERROR] Failed to connect to APNs
Traceback (most recent call last):
  File "/home/.../helpers.py", line 635, in send_push
    ret = srv.send(message)
  File "/.../lib/python3.4/site-packages/apns_clerk/apns.py", line 96, in send
    status = self._connection.send(message)
  File "/.../lib/python3.4/site-packages/apns_clerk/transport.py", line 261, in send
    with self:
  File "/.../lib/python3.4/site-packages/apns_clerk/transport.py", line 234, in __enter__
    self._open_connection()  # can raise exception, bubblit up to the top
  File "/.../lib/python3.4/site-packages/apns_clerk/transport.py", line 550, in _open_connection
    timeout=self.session.connect_timeout
  File "/.../lib/python3.4/site-packages/apns_clerk/backends/__init__.py", line 89, in get_cached_connection
    return self.get_new_connection(address, certificate, timeout=timeout)
  File "/.../lib/python3.4/site-packages/apns_clerk/backends/stdio.py", line 414, in get_new_connection
    return self.connection_class(address, certificate, timeout=timeout)
  File "/.../lib/python3.4/site-packages/apns_clerk/backends/stdio.py", line 154, in __init__
    self._open_connection(timeout)
  File "/.../lib/python3.4/site-packages/apns_clerk/backends/stdio.py", line 168, in _open_connection
    self._connect_and_handshake()
  File "/.../lib/python3.4/site-packages/apns_clerk/backends/stdio.py", line 205, in _connect_and_handshake
    self._connection.do_handshake()
  File "/.../lib/python3.4/site-packages/OpenSSL/SSL.py", line 1442, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/.../lib/python3.4/site-packages/OpenSSL/SSL.py", line 1163, in _raise_ssl_error
    raise WantReadError()
OpenSSL.SSL.WantReadError
@MarSoft

This comment has been minimized.

Copy link

commented Sep 1, 2015

Looks like we should use eventlet's version of OpenSSL. Here is my (very dirty) workaround, for now couldn't figure out anything better:

  • in eventlet/green/OpenSSL/init.py fix imports to be compatible with python3 (import rand -> from . import rand)
  • In apns_clerk/backends/stdio.py replace import OpenSSL with from eventlet.green import OpenSSL.
    This worked for me. (Another issue is it hangs if there is only one valid device, I worked it around by adding «dummy» invalid device.) I believe there is a better way to make apns_clerk use greenified OpenSSL, but I couldn't figure it out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.