How to use wallet connect client on localhost with websocket?

252 Views Asked by At

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?

1

There are 1 best solutions below

0
Kitty Kad On

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.