michaelhly / solana-py

Solana Python SDK

Home Page:https://michaelhly.github.io/solana-py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Websocket randomly exits with Error 1006

jmvsrules opened this issue · comments

Hey,

I recently noticed that my Solana.py websocket sometimes just randomly disconnects from the RPC server I am currently using. The websocket logging gave following result:

% sending keepalive ping
> PING 28 cc ef 76 [binary, 4 bytes]
< PONG 28 cc ef 76 [binary, 4 bytes]
% received keepalive pong
< PING '' [0 bytes]
> PONG '' [0 bytes]
= connection is CLOSED
! failing connection with code 1006
x closing TCP connection

Is there anything I can do to prevent these from happening and breaking? I don't know if it's an error by the RPC provider or from my side and I really would like to prevent these from happening.
I am using solana v0.30.2 (from pip) and therefore websockets v11.0.3.

Thanks for your help!

Some more information as I just saw I didn't include it.

I'm using the
async with connect() as websocket and then the
for idx, msg in asyncstdlib.enumerate(websocket) method.

I'm using the Alchemy websocket, it may also be an error on their side, I am not 100% sure about it.

The websocket functionality is a wrapper around https://github.com/python-websockets/websockets

If possible, would be great if you can try recreate it with that library so we know if there's a problem on the solana-py side specifically

Hey, yeah I can try it although I'll need to look a bit into that library. As stated earlier, it might also just be that the RPC provider messes up after some time. I'll come back with updates as soon as I got them!

Hey, I just checked and it appears also when using the websockets library. I also tried it with an other RPC provider (Quicknode) and the same error happened. So I guess it just is something that occasionally happens and is not Solana.py-related. Do you know though if there is something to avoid this?