bitlogik / pyWalletConnect

WalletConnect implementation for Python wallets
GNU General Public License v3.0
47 stars 15 forks source link

pywalletconnect.client.WCClientException: Topic subcription timeout #15

Closed snarflakes closed 1 year ago

snarflakes commented 1 year ago

I'm using the most currently pyWalletConnect

Testing V2 connections using: https://github.com/WalletConnect/web-examples

using: React dApp (with standalone client) - v2 (Demo)

I try to connect and it says: pywalletconnect.client.WCClientException: Topic subcription timeout

I'm able to connect fine currently on Opensea: which sends me V1 walletconnect using the same code.

ERROR code:

pyWalletConnect minimal demo scanned a Dapp WC URI (v1 or v2) >) DEBUG:pywalletconnect.client_v2irn:URI WC version 2 decoding DEBUG:pywalletconnect.client_v2irn:wc v2 URI provided decoded successfully, now starting the WalletConnect client DEBUG:pywalletconnect.client_v2irn:Opening a WalletConnect v2 client with https://relay.walletconnect.com/?auth=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkaWQ6a2V5Ono2TWtndDRTeGpzdXdTeFhTeHJnTkphSFJkWXBBaURCVXpYYjdoeUZrblQ2NVdlMSIsInN1YiI6ImUyNDgxOTE3ZTUzM2VmYjUyZjdlNzFiMWQyOGE2NDQxNTQ5NGVhNWM2NGNkMWI3ZTRjODJlMWQ0NjRjNjBhY2YiLCJhdWQiOiJ3c3M6Ly9yZWxheS53YWxsZXRjb25uZWN0LmNvbSIsImlhdCI6MTY4NzAyMTgxMCwiZXhwIjoxNjg3MTA4MjEwfQ.fae2cANuViZJigjSe9XerW5yEYwhOBXOBWDFmd8bpTDO1C6XWiFcnIjjpmgf_sHOzu268l6DeYI-QsIj39S_CA&projectId=338d2404fafcd317347e4da1c3de72b5&ua=wc-2/python-1/desktop/pyWalletConnect DEBUG:pywalletconnect.tls_socket:Socket connected DEBUG:pywalletconnect.websocket:Connecting to WebSocket Host=relay.walletconnect.com PathTarget=/?auth=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkaWQ6a2V5Ono2TWtndDRTeGpzdXdTeFhTeHJnTkphSFJkWXBBaURCVXpYYjdoeUZrblQ2NVdlMSIsInN1YiI6ImUyNDgxOTE3ZTUzM2VmYjUyZjdlNzFiMWQyOGE2NDQxNTQ5NGVhNWM2NGNkMWI3ZTRjODJlMWQ0NjRjNjBhY2YiLCJhdWQiOiJ3c3M6Ly9yZWxheS53YWxsZXRjb25uZWN0LmNvbSIsImlhdCI6MTY4NzAyMTgxMCwiZXhwIjoxNjg3MTA4MjEwfQ.fae2cANuViZJigjSe9XerW5yEYwhOBXOBWDFmd8bpTDO1C6XWiFcnIjjpmgf_sHOzu268l6DeYI-QsIj39S_CA&projectId=338d2404fafcd317347e4da1c3de72b5&ua=wc-2/python-1/desktop/pyWalletConnect DEBUG:pywalletconnect.websocket:Waiting WebSocket handshake : 1th loop. DEBUG:pywalletconnect.websocket:Waiting WebSocket handshake : 2th loop. DEBUG:pywalletconnect.websocket:Waiting WebSocket handshake : 3th loop. DEBUG:pywalletconnect.websocket:WebSocket connection established. DEBUG:pywalletconnect.client_v2irn:wc v2 URI and project id accepted Connecting with the Dapp ... DEBUG:pywalletconnect.client_v2irn:Sending a subscription request for d41cc7568d89560a55a04a72ebd3d34364ff474e1447e81f55fece033bd4a1df. DEBUG:pywalletconnect.client:WalletConnect message sending to relay : {"jsonrpc":"2.0","id":1,"method":"irn_subscribe","params":{"topic":"d41cc7568d89560a55a04a72ebd3d34364ff474e1447e81f55fece033bd4a1df"}} DEBUG:pywalletconnect.client_v2irn:Waiting for Topic subcription ack. DEBUG:pywalletconnect.websocket:WebSocket Text message received : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client_v2irn:A JSON message in the queue : {"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Request validation error: Invalid request ID"}} DEBUG:pywalletconnect.client:Closing WalletConnect link. DEBUG:pywalletconnect.websocket:Cancelling the WebSocket reading timer DEBUG:pywalletconnect.websocket:Closing WebSocket DEBUG:pywalletconnect.tls_socket:Closing socket Traceback (most recent call last): File "imageidopen.py", line 848, in qr_capture session_data = wclient.open_session() File "/home/pi/.local/lib/python3.7/site-packages/pywalletconnect/client_v2irn.py", line 235, in open_session self.subscribe(self.proposal_topic) File "/home/pi/.local/lib/python3.7/site-packages/pywalletconnect/client_v2irn.py", line 204, in subscribe subscription_id = self.wait_for_response("Topic subcription") File "/home/pi/.local/lib/python3.7/site-packages/pywalletconnect/client_v2irn.py", line 185, in wait_for_response raise WCClientException(f"{resp_type} timeout") pywalletconnect.client.WCClientException: Topic subcription timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/gpiozero/pins/rpigpio.py", line 223, in _call_when_changed super(RPiGPIOPin, self)._call_when_changed() File "/usr/local/lib/python3.7/dist-packages/gpiozero/pins/local.py", line 130, in _call_when_changed self.state if state is None else state) File "/usr/local/lib/python3.7/dist-packages/gpiozero/pins/pi.py", line 298, in _call_when_changed method(ticks, state) File "/usr/local/lib/python3.7/dist-packages/gpiozero/input_devices.py", line 182, in _pin_changed self._fire_events(ticks, bool(self._state_to_value(state))) File "/usr/local/lib/python3.7/dist-packages/gpiozero/mixins.py", line 401, in _fire_events self._fire_activated() File "/usr/local/lib/python3.7/dist-packages/gpiozero/mixins.py", line 447, in _fire_activated super(HoldMixin, self)._fire_activated() File "/usr/local/lib/python3.7/dist-packages/gpiozero/mixins.py", line 364, in _fire_activated self.when_activated() File "imageidopen.py", line 320, in push_button2 qr_capture() File "imageidopen.py", line 1092, in qr_capture except pywalletconnect.client.WCClientException: NameError: name 'pywalletconnect' is not defined pywalletconnect.client.WCClientException: Topic subcription timeout

bitlogik commented 1 year ago

Thx for the report. It works weeks ago. The first trail is there could be a change in the relay.walletconnect.com service, it seems to only accept RPC id being a string. We'll confirm that and eventually report to the walletconnect relay service, as this is a violation of the JSON-PRC standard. Of course we consider a new release with this restriction used. Not sure, as the release process is not so simple, for a little change like that. Still, our team might be more agile than the walletconnect one.

bitlogik commented 1 year ago

Now confirm the issue is the id of the JSON-RPC request must be a large number (representing the time), and a small number is rejected. This is not documented and the official documentation uses 1, which is no more working.

bitlogik commented 1 year ago

We'll release a new version with some fixes. Note that this will require Python 3.7+ (no more working on 3.6). you're on 3.7 so that's OK. We'll take care to write this change in the doc (for those using 3.6).