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

Getting 'socket stalled' exception which causes MAUI Blazor (Android) to crash #122

Closed
mehrandvd opened this issue Sep 21, 2023 · 0 comments · Fixed by #124
Closed

Getting 'socket stalled' exception which causes MAUI Blazor (Android) to crash #122

mehrandvd opened this issue Sep 21, 2023 · 0 comments · Fixed by #124
Assignees

Comments

@mehrandvd
Copy link

The following code throws this exception randomly:

Exception: socket stalled
at WalletConnectSharp.Common.Utils.Extensions.<WithTimeout>d__5.MoveNext()
   at WalletConnectSharp.Core.Controllers.Relayer.<>c__DisplayClass52_0.<<TransportOpen>g__Task2|2>d.MoveNext()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()

The source code:

var dappOptions = new SignClientOptions()
            {
                ProjectId = "XXXXXXXXXX",
                Metadata = new Metadata()
                {
                    Description = "Functionland Blox",
                    Icons = new[] { "https://fx.land/blox-icon.png" },
                    Name = "Functionland Blox",
                    Url = "https://fx.land/"
                },
            };

            var dappConnectOptions = new ConnectOptions()
            {
                RequiredNamespaces = new RequiredNamespaces()
                {
                    {
                        "eip155", new ProposedNamespace
                        {
                            Methods = new[]
                            {
                                "eth_sendTransaction",
                                "eth_signTransaction",
                                "eth_sign",
                                "personal_sign",
                                "eth_signTypedData",
                            },
                            Chains = new[]
                            {
                                "eip155:1"
                            },
                            Events = new[]
                            {
                                "chainChanged",
                                "accountsChanged",
                            }
                        }
                    }
                }
            };

            var dappClient = await WalletConnectSignClient.Init(dappOptions);
            // throws exception here

In Windows, it is an exception that we can catch, but in MAUI Blazor (Android) causes the app to crash even if everything is in a try-catch.

I've checked the source code and it seems it's because of this line:

await this.Provider.Connect().WithTimeout(TimeSpan.FromSeconds(5), "socket stalled");

There is a hardcoded 5-second timeout that can not be configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants