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

Unable to correctly receive messages when there are two WebSocket connections in a dApp #5542

Closed
Lbqds opened this issue Dec 9, 2024 · 3 comments
Assignees
Labels
type: bug Something isn't working

Comments

@Lbqds
Copy link

Lbqds commented Dec 9, 2024

Describe the bug
Unable to correctly receive messages when there are two WebSocket connections in a dApp

SDK Version

  • Client: [JS]
  • Version [2.17.2]

My dApp requires interacting with two blockchains simultaneously, so I have two WebSocket connections running concurrently. It worked fine before, but today during testing, I discovered that it cannot correctly receive messages from the wallet. I tried upgrading to the latest WalletConnect version, but the issue persists. Below is some detailed information:

  1. Connect to Chain-A's wallet via WalletConnect. As shown in the screenshot below, it successfully sends a subscribe request and receives a response (let's call it connection-A):

connection-a-subscribe
connection-a-response

  1. Connect to Chain-B's wallet via WalletConnect. It also successfully sends a subscribe request(let's call it connection-B):

connection-b-subscribe

  1. Send a request to the Chain-A's wallet via WalletConnect, connection-A does not receive the response from the wallet. Instead, the response is received by connection-B. The following screenshot shows the message from connection-B. As you can see, the topic id of the message it received corresponds to connection-A, which is very strange.

connection-b-response

Could this be caused by an issue with the relay server when sending the messages?

@Lbqds Lbqds added the type: bug Something isn't working label Dec 9, 2024
@ganchoradkov
Copy link
Member

hey @Lbqds, sorry for the late response! By having multiple connections I would assume you initialize the client multiple times? This is not recommened approach as clients share storage and this can lead to conflicts. Given that the client is multi-chain/multi-session by default, you should be able to connect to as many chains/sessions with a single client instance thus avoiding your multi-socket issue

@ganchoradkov ganchoradkov closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
@ganchoradkov
Copy link
Member

ganchoradkov commented Dec 20, 2024

to add to the explanation, your issue is caused exactly by theclients sharing storage. Both clients subscribe to the same topics and only the latest (in this case client B) receives the messages.
As last resort the clients accept customStoragePrefix init parameter that you can set and isolate the storages per client and avoid the issue but again, the recommened way is to use single client for all your sessions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants