Crypto-toolbox / btfxwss

Bitfinex Websocket API Client written in Python3
MIT License
284 stars 125 forks source link

websockets reconnecting constantly? #163

Open Indiana3714 opened 6 years ago

Indiana3714 commented 6 years ago

Had this issue for months already recently (fine before), is this an issue with the code or bitfinex's side? `12:43:50 PM - $6455.9 0.0246 12:43:50 PM - $6455.9 0.2324 12:43:59 PM - $6455.9 0.0031 BOUGHT send: b'\x88\x82v&q\xdau\xce' --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: fMGRPUZ7+JJsLgCOZbooUg== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:44:28 GMT Connection: upgrade Set-Cookie: __cfduid=d4fb0d89d75e26d1cb252ef7f58f8d4e61541987067; expires=Tue, 12-Nov-19 01:44:27 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: mA6/5p7UWIKebTS3BEcQM2V3YpU= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 47855043be4365bd-SYD

send: b'\x81\x91\x1b#y\x0c`\x01\x1cz~M\r.!\x03[|rM\x1e.f' send: b'\x81\xbf\x1a\xba\x18\xc0a\x98}\xb6\x7f\xd4l\xe2 \x9a:\xb3o\xd8k\xa3h\xd3z\xa58\x968\xe2y\xd2y\xaet\xdft\xe2 \x9a:\xb4h\xdb|\xa5i\x984\xe08\xc9a\xadx\xd5t\xe2 \x9a:\x82N\xf9M\x93^\x98e' 12:44:48 PM - $6455.8 0.0068 SOLD send: b'\x88\x82x\xda\x0b\x8a{2' --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: nJAlomTFLGSKsCwjghsm3A== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:45:13 GMT Connection: upgrade Set-Cookie: __cfduid=ddd6c78219e2585abb246e4ab47f6fc631541987112; expires=Tue, 12-Nov-19 01:45:12 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: iaooUUqFoZVQFBa0ZqSJynVgrvI= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 4785515d5a9a6575-SYD

send: b'\x81\x91\xa1\xbe\xb3P\xda\x9c\xd6&\xc4\xd0\xc7r\x9b\x9e\x91 \xc8\xd0\xd4r\xdc' send: b'\x81\xbf\x06\xf8M\xd9}\xda(\xafc\x969\xfb<\xd8o\xaas\x9a>\xbat\x91/\xbc$\xd4m\xfbe\x90,\xb7h\x9d!\xfb<\xd8o\xadt\x99)\xbcu\xdaa\xf9$\x8b4\xb4d\x97!\xfb<\xd8o\x9bR\xbb\x18\x8aB\xda0' 12:45:39 PM - $6455.8 0.0295 send: b'\x88\x82h\x0eB-k\xe6' --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: u258/TwJogjhWo/Y9OtcKQ== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:46:28 GMT Connection: upgrade Set-Cookie: __cfduid=d5da73a7f87c88675d7e4ed948623dba71541987187; expires=Tue, 12-Nov-19 01:46:27 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: 1XUZpSgagFbOjLpGOg2ICGIview= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 47855332684065b1-SYD

send: b'\x81\x91\x91\x99A\xee\xea\xbb$\x98\xf4\xf75\xcc\xab\xb9c\x9e\xf8\xf7&\xcc\xec' send: b'\x81\xbf\x11D3\x81jfV\xf7t*G\xa3+d\x11\xf2d&@\xe2c-Q\xe43h\x13\xa3r,R\xef\x7f!\xa3+d\x11\xf5c%W\xe4bf\x1f\xa137J\xecs+\xa3+d\x11\xc3E\x07f\xd2UfN' 12:46:32 PM - $6455.8 0.0068 SOLD 12:47:04 PM - $6455.8 0.0170 12:47:33 PM - $6455.8 0.1011 12:47:33 PM - $6455.8 0.1288 send: b'\x88\x82M,0\x1fN\xc4' --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: xPqKfUCcKcqmWtYcDH5dvg== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:48:28 GMT Connection: upgrade Set-Cookie: __cfduid=d5edf540c54c76747b4f2dc857806729c1541987307; expires=Tue, 12-Nov-19 01:48:27 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: nHOim4Fdgb8c3D+bD2Qbu3cA6nI= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 478556202a5965f9-SYD

send: b'\x81\x91\xce\xdc~&\xb5\xfe\x1bP\xab\xb2\n\x04\xf4\xfc\V\xa7\xb2\x19\x04\xb3' send: b'\x81\xbf\xe5\x062\x18\x9e$Wn\x80hF:\xdf&\x10k\x90dA{\x97oP}\xc7*\x12:\x86nSv\x8bc^:\xdf&\x10l\x97gV}\x96$\x1e8\xc7uKu\x87i^:\xdf&\x10Z\xb1EgK\xa1$O' send: b'\x88\x82\x88\xd2\x0c\xc9\x8b:' --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: SvtAiKvX7ufz4zhWM7OQHA== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:48:50 GMT Connection: upgrade Set-Cookie: __cfduid=d45125df66817330e58e2a5b735450cd81541987329; expires=Tue, 12-Nov-19 01:48:49 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: aA04mZq9jXALVHFhfu7IcNZ+HN8= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 478556aa3f5865c9-SYD

send: b'\x81\x91\xa3\xd9U\xc2\xd8\xfb0\xb4\xc6\xb7!\xe0\x99\xf9w\xb2\xca\xb72\xe0\xde' send: b'\x81\xbf\x08Z\xeb\xa3sx\x8e\xd5m4\x9f\x812z\xc9\xd0}8\x98\xc0z3\x89\xc6v\xcb\x81k2\x8a\xcdf?\x87\x812z\xc9\xd7z;\x8f\xc6{x\xc7\x83)\x92\xcej5\x87\x812z\xc9\xe1\\x19\xbe\xf0Lx\x96' send: b"\x88\x82\xfa\x05'(\xf9\xed" --- request header --- GET /ws/2 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: api.bitfinex.com Origin: http://api.bitfinex.com Sec-WebSocket-Key: ccDtqIm/LfulcnXEAdgnPg== Sec-WebSocket-Version: 13


--- response header --- HTTP/1.1 101 Switching Protocols Date: Mon, 12 Nov 2018 01:49:12 GMT Connection: upgrade Set-Cookie: __cfduid=d16ec2613123ff6a854808d773d488b3a1541987351; expires=Tue, 12-Nov-19 01:49:11 GMT; path=/; domain=.bitfinex.com; HttpOnly Upgrade: websocket Sec-WebSocket-Accept: oVUPVshUTqn55cSMVl4rzjknsHE= Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 478557322a9419ce-SYD

send: b'\x81\x91y%T[\x02\x071-\x1cK yC\x05v+\x10K3y\x04' send: b"\x81\xbf\x07,^h|\x0e;\x1ebBJ=\x0c|\x1brN-\x0buE<\r%\x00~JdD?\x06iI2J=\x0c|\x1cuM:\rt\x0erH%_'\x05eC2J=\x0c|So\x0b;C\x0e#" 12:49:50 PM - $6455.9 0.2512 12:49:52 PM - $6455.8 0.0250 12:50:08 PM - $6455.9 0.0348`

51bitquant commented 5 years ago

Yes, I don't know why, the server send the heartbeat to the client, and don't need to constantly reconnect constantly.

51bitquant commented 5 years ago

I check that it seem you don't manage the heartbeat properly, it was not cause by the network, I use the Bitfinex Official framework, it do handle the websockets properly.