Open TheOneVries opened 1 week ago
Question: are you using ABI to C# contract generator?
Yes I do, but this is not happening via contract calls; this happens on initial wallet connect. Sorry I should have clarified further.
So in my connect script I call await Web3Unity.Instance.Initialize(rememberMe);
Somewhere during this process it seems public async Task Close()
appears to be called in CSWebSocket.cs (in the WebSocket
class), which is where this error can occur...
I should mention that this happens in the editor, and I've also noticed that this never happens on first play, so this might have to do with objects not properly being disposed of when stopping a game and starting again? Either way, I've put the code in Task Close() in a try-catch like so:
public async Task Close()
{
if (State == WebSocketState.Open)
{
try
{
await m_Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, m_CancellationToken);
}
catch (Exception e)
{
UnityEngine.Debug.LogWarning(">> WebSocket exception: " + e.Message);
}
}
}
And this seems to work fine... even when I try to connect and it catches an exception (which typically has the message 'Aborted'), the connection still ends up being successful. So yeah; I suspect this error is actually caused by the Close() being called via objects still lingering from a previous session, except the object they're calling it on no longer exists? Something like that? Either way, I think for editor purposes a try/catch solves it. For me it does :D
If you want , you can add that fix to our repo and help us out in true open-source manner. We would be more than happy to accept your PR!
When connecting to wallet using the 'remember me' functionality, using admittedly not the most reliable internet connection, I regularly find unity crash when calling
public async Task Close()
on CSWebSocket.csThis is a connection made via WalletConnect, connecting to MetaMask. Mostly this works fine, but occasionally this error occurs, leading me to believe the issue lies with internet connection.
I am afraid I cannot provide a sample project or anything.
Console errors
Desktop (please complete the following information):