Kitty Kad
Kitty Kad

Reputation: 444

How to use wallet connect client on localhost with websocket?

I was trying to test wallet connect locally and initializing the client like this. (note

      const _client = await Client.init({
        relayUrl: "ws://localhost.com:3000",
        projectId: projectId, // ID registered on wallet connect
      });

However when making the client, I get this error

{context: 'core'} {context: 'core/relayer'} Error: Socket stalled when trying to connect to ws://localhost.com:3000
    at watch.ts:37:1

I'm guessing its to do with web sockets not working properly on my local host? Not sure if it's related to needing to configure my JS client to somehow expose websockets on localhost?

Upvotes: 1

Views: 1214

Answers (1)

Kitty Kad
Kitty Kad

Reputation: 444

Relay URL is optional and defaults to whatever wallet connect provides. Locally my app wasn't running a special server for the socket which is likely why it was failing.

Unless there is a need to run your own relay url, you can default to the one provided by wallet connect and remove relayUrl from the config completely.

Upvotes: 1

Related Questions