tkp-archive / pyEX

Python interface to IEX and IEX cloud APIs
https://pyex.readthedocs.io
Apache License 2.0
408 stars 110 forks source link

Handle Reconnection #42

Closed rjemanuele closed 5 years ago

rjemanuele commented 5 years ago

Hi,

I'm using this get the TOPS Websocket feed. Does it handle reconnecting if it gets disconnected?

Running with logging at info level.

WARNING:socketIO-client:ws-api.iextrading.com:443/socket.io [connection error] recv disconnected (Connection is already closed.)
WARNING:socketIO-client:ws-api.iextrading.com:443/socket.io [connection error] recv disconnected ([Errno 11] Resource temporarily unavailable)

Thanks for the great work on this!

timkpaine commented 5 years ago

@rjemanuele I don't think so, but im waiting for the new iexcloud release, hopefully that will bring a more stable streaming interface

rjemanuele commented 5 years ago

@timkpaine I'd figure the reconnect would be handled at the socket.io level. Until this morning at around 8am PST my TOPS connection was pretty good. It was disconnected and when I restarted the program, I've started getting

WARNING:socketIO-client:ws-api.iextrading.com:443/socket.io [connection error] recv disconnected ([Errno 11] Resource temporarily unavailable)

Full demo:

Python 3.7.1 (default, Nov 16 2018, 22:26:09)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyEX
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> ws = pyEX.topsWS(symbols=['SPY'])
>>> ws.run()
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ws-api.iextrading.com:443
DEBUG:urllib3.connectionpool:https://ws-api.iextrading.com:443 "GET /socket.io/?EIO=3&transport=polling&t=1547679461970-0 HTTP/1.1" 200 None
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [engine.io transport selected] websocket
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [engine.io heartbeat reset]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet sent] 0/1.0/tops,
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io /1.0/tops [socket.io waiting for connection]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet received] b'0'
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io connected]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io /1.0/tops [socket.io waiting for connection]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io /1.0/tops [socket.io waiting for connection]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet received] b'0/1.0/tops,'
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io /1.0/tops [socket.io connected]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet sent] 2/1.0/tops,["subscribe", "SPY"]
WARNING:socketIO-client:ws-api.iextrading.com:443/socket.io [connection error] recv disconnected ([Errno 11] Resource temporarily unavailable)
DEBUG:urllib3.connectionpool:https://ws-api.iextrading.com:443 "GET /socket.io/?EIO=3&transport=polling&t=1547679463543-0 HTTP/1.1" 200 None
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [engine.io transport selected] websocket
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet sent] 0/1.0/tops,
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [engine.io heartbeat reset]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet received] b'0'
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io connected]
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io [socket.io packet received] b'0/1.0/tops,'
DEBUG:socketIO-client:ws-api.iextrading.com:443/socket.io /1.0/tops [socket.io connected]

Now there is that "Resource temporarily unavailable" in there.

Thanks.

timkpaine commented 5 years ago

Closing for IEX cloud version