Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing exceptions when after few minutes with no interaction #79

Closed
axenteoctavian opened this issue Mar 8, 2023 · 13 comments · Fixed by #141 or #170
Closed

Throwing exceptions when after few minutes with no interaction #79

axenteoctavian opened this issue Mar 8, 2023 · 13 comments · Fixed by #141 or #170
Assignees
Labels
bug Something isn't working v2 This issue relates to v2 of WalletConnect

Comments

@axenteoctavian
Copy link

axenteoctavian commented Mar 8, 2023

I am connecting to my wallet with something like this:

_client = await WalletConnectSignClient.Init(_dappOptions);
_walletConnectV2 = await _client.Connect(_dappConnectOptions);
_walletConnectV2Session = await _walletConnectV2.Approval;

There are 2 errors that happen after some time of inactivity doing nothing:
1.
image

  1. When this happens, the storage file is broken and will throw errors after I start the application again
    image

Thank you! 🙏

@0cv
Copy link

0cv commented Apr 22, 2023

Similar here. I've the stack trace from the Godot Debugger. This seems to happen regardless of whether the QR code is scanned or ignored (Approval method passing)

E 0:08:09:0026   :0 @ void WalletConnectSharp.Network.Websocket.WebsocketConnection.OnOpen(Websocket.Client.WebsocketClient ): System.NullReferenceException: Object reference not set to an instance of an object.
  <C++ Error>    System.NullReferenceException
  <C++ Source>   :0 @ void WalletConnectSharp.Network.Websocket.WebsocketConnection.OnOpen(Websocket.Client.WebsocketClient )
  <Stack Trace>  :0 @ void WalletConnectSharp.Network.Websocket.WebsocketConnection.OnOpen(Websocket.Client.WebsocketClient )
                 :0 @ void WalletConnectSharp.Network.Websocket.WebsocketConnection+<Register>d__21.MoveNext()
                 :0 @ void System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task )
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task )
                 :0 @ void WalletConnectSharp.Network.Websocket.WebsocketConnection+<Open>d__19.MoveNext()
                 :0 @ void System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task )
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task )
                 :0 @ void WalletConnectSharp.Network.JsonRpcProvider+<Connect>d__19.MoveNext()
                 :0 @ void System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task )
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task )
                 :0 @ void WalletConnectSharp.Network.JsonRpcProvider+<Connect>d__21.MoveNext()
                 :0 @ void System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task )
                 :0 @ void System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task )
                 :0 @ void WalletConnectSharp.Core.Controllers.Relayer+<<RegisterEventListeners>b__36_2>d.MoveNext()
                 :0 @ void System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                 :0 @ void System.Threading.Tasks.Task+<>c.<ThrowAsync>b__128_1(System.Object )
                 :0 @ Boolean System.Threading.ThreadPoolWorkQueue.Dispatch()
                 :0 @ void System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
                 :0 @ void System.Threading.Thread.StartCallback()

@gigajuwels gigajuwels self-assigned this May 9, 2023
@fudgebucket27
Copy link

fudgebucket27 commented Jun 11, 2023

I have the same issue too. Though I'm attempting with Blazor WASM...

EDIT: Disregard this. I'm trying to scan with the Loopring Wallet which only supports Sign V1...

@gigajuwels
Copy link
Contributor

This has been fixed in 2.0.5 can you confirm?

@gigajuwels gigajuwels added bug Something isn't working v2 This issue relates to v2 of WalletConnect labels Jun 13, 2023
@axenteoctavian
Copy link
Author

This has been fixed in 2.0.5 can you confirm?

Hi @gigajuwels!
The SDK is not throwing the exceptions mentioned above anymore.

But something is happening behind the scenes (every minute there are some exceptions happening)
image

What I can see is that these exceptions behind the scenes are affecting the requests/events
It will crash if I call _client.Disconnect(...) and the afferent event is not triggered

 _client.On(SESSION_DELETE, delegate ()
{
    OnSessionDeleteEvent?.Invoke(this, EventArgs.Empty);
});

image

also if I use _client.Request<T, TR>(...) I get the request on my phone but the response is not received by the SDK

@VR-Innovations
Copy link

Still have the same issue. As written in the referenced posts above.

@skibitsky
Copy link
Member

Cannot reproduce after Release 2.1.1 #129

@axenteoctavian
Copy link
Author

axenteoctavian commented Oct 17, 2023

@skibitsky the issue is not really resolved for me on version 2.1.1
This is kind of an old issue, I created a new one some time ago but @gigajuwels closed it.

Look at these steps to reproduce the broken connection
#117 (comment)

It has been almost 8 months since I posted this issue and is still not resolved. Please let me know if you need any more info.
Thank you! 🙏

@skibitsky skibitsky reopened this Oct 17, 2023
skibitsky added a commit that referenced this issue Oct 17, 2023
@skibitsky
Copy link
Member

Thanks, @axenteoctavian!

This issue was caused by WebSocket.Client library used by WalletConnectSharp. Initially I was unable to reproduce it in WalletConnectUnity because in Unity we use another library for websockets.

I've opened a PR #141 with a potential fix. Could you please check if it resolves the issue for you?

@axenteoctavian
Copy link
Author

Hi @skibitsky!

This PR got something right.
But in my tests now, the same thing happens but after 5 minutes.😅

@skibitsky
Copy link
Member

skibitsky commented Oct 19, 2023

Thanks, @axenteoctavian!

I was able to reproduce and fix the issue in the same PR. WebSocket reconnection logic was broken.

@vorberohus
Copy link

Hi @skibitsky!

I'm trying to use WalletConnectUnity and I think this issue still persists.

If I understand correctly after the socket is closed the Relayer should attempt to reconnect and all the commutication should return to normal.

I've added this to WCWebSocket to reproduce the issue

void Update()
{
//This part to reproduce the issue
    i++;
    if (i % 5000 == 0)
        Close();
// - This part to reproduce the issue

#if !UNITY_WEBGL || UNITY_EDITOR
    if (_socket != null)
        _socket.DispatchMessageQueue();
#endif
}

image

After the the socket disconnects though it shows a log from JsonRpcProvider that the connection is opening no further communication is possible. New calls to SignClient.Connect() don't work.

I'm testing this because the disconnect still happens automatically after some time.

Maybe I'm doing somthing wrong and you can help with this. Thanks!

@skibitsky
Copy link
Member

Hi @vorberohus,

Your are right, and sorry for that. WalletConnectUnity and WalletConnectSharp aren't in full sync, I wanted to push one more PR before making release and merging it into WalletConnectUnity.

I've just merged v2.1.2 into WalletConnectUnity, it will fix the issue for you.

@axenteoctavian
Copy link
Author

Thanks, @axenteoctavian!

I was able to reproduce and fix the issue in the same PR. WebSocket reconnection logic was broken.

Hi @skibitsky!
This error happens again starting with version 2.1.3.

After 5 mins without interaction, the request is received in my wallet, but the response is not coming back.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2 This issue relates to v2 of WalletConnect
Projects
None yet
7 participants