magicblock-labs / Solana.Unity-SDK

Open-Source Unity-Solana SDK with Full RPC coverage, NFT support and more
https://solana.unity-sdk.gg
MIT License
157 stars 89 forks source link

[Bug] WebSocket connection does not handle errors well and there is no retry #184

Closed Woody4618 closed 11 months ago

Woody4618 commented 1 year ago

Describe the bug 1) When subscribing to accounts before the websocket connection is established the subscribtions get lost without an error message: telegram-cloud-photo-size-2-5298759350338310336-y

telegram-cloud-photo-size-2-5298759350338310352-y

2) When subscribing to the account on multiple channels none of the subscriptions trigger anymore.

3) When Socket connection looses connection, when running for a while in a webgl build for example, there is no automatic reconnect.

4) Socket subscribe functions default to finalized, I would recommend using confirmed commitment.

To Reproduce Reprouction can be found in this project in the TokenPanel. The subscription only works When waiting a few seconds after the Login happened. https://github.com/solana-developers/solana-game-starter-kits/blob/main/lumberjack/unity/Lumberjack/Assets/Game/Scripts/Ui/TokenPanel.cs I added a bunch of comments to the file for easy reproduction.

Expected behavior I would like an implementation like here: https://github.com/solana-developers/solana-game-starter-kits/blob/main/seven-seas/unity/Assets/SolPlay/Scripts/Services/SolPlayWebSocketService.cs

Where the subscriptions are saved independant from the socket state and when the sockets connects or reconnects the subscriptions get reapplied.

GabrielePicco commented 1 year ago

Thanks for opening the PR. Done some initial work in #186.