Closed davidkamura closed 1 month ago
Why is the connection closed when queuedMessages.length is zero while in future the websocket connection may receive messages
This is what actually happens:
So the queue is your red herring. It's neither here nor there; the problem is that your websocket is nuking.
Now, look at the actual error. You received websocket close code 1006. Looking that up:
Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.
So your provider nuked your connection, without warning, without a reason, and without due process.
If you would like to continue this conversation, please do so on Stack Exchange, linked below. Almost certainly what's happening is that walletsToTrack
is too large, and your provider is refusing to allow you to make that many subscriptions over a single channel. Related discussion: #3380.
Hi @davidkamura,
Thanks for your question!
We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of the Solana JavaScript SDK itself.
Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with the Solana JavaScript SDK itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask
This automated message is a result of having added the ‘question’ tag.
steveluscher thanks for the explanation, it's cleared a lot on this issue. It seems that the walletsToTrack
is indeed creating to many subscriptions which can't be supported by the rpc endpoint
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.
Overview
I'm building a transaction tracking library which has the ability to subscribe multiple addresses to their log notifications concurrently. The log notifications from the different addresses are merged and streamed to
consumeLogs
function. The issue arises when the websocket does not receive messages for a variable amount of time - causing abrupt closure of the websocket connection. It throws the following error.Error Message
In this case the websocket connection closed within 7 minutes of inactivity
Description of bug
It seems that websocket-connection.ts causes this disconnection as the logic implemented closes the connection when `queuedMessages.length is 0
websocket-connection.ts in
handleOpen()
Steps to reproduce
Below is the applications code:
Create log notification subscriptions for multiple addresses
Merge log notificatons of the different addresses and stream them as one
Consume the merged logs
Conclusion
a) Why is the connection closed when
queuedMessages.length
is zero while in future the websocket connection may receive messages b) How can this be fixed and allow for the websocket connection to be kept alive infinitely?