Websocket issue on project: DABL
Hi. I am experimenting with Project dable
I deployed my app to
nxhgy6yk92nxerri
But I am receiving a websocket fail upon retrieving some of my data
This is what is displayed in my dev console
index.js:478 WebSocket connection to ‘wss://api.projectdabl.com/data/nxhgy6yk92nxerri/v1/stream/query’ failed: Error during WebSocket handshake: Unexpected response code: 403 e.streamSubmit @ index.js:478 e.streamQuery @ index.js:586 (anonymous) @ createLedgerContext.js:170 is @ react-dom.production.min.js:211 mu @ react-dom.production.min.js:257 t.unstable_runWithPriority @ scheduler.production.min.js:19 Ui @ react-dom.production.min.js:122 bu @ react-dom.production.min.js:257 (anonymous) @ react-dom.production.min.js:256 z @ scheduler.production.min.js:17 S.port1.onmessage @ scheduler.production.min.js:14 react_devtools_backend.js:2273 useStreamQuery: web socket closed {code: 1006, reason: “”}
Hi @bartcant
From the error message: Error during WebSocket handshake: Unexpected response code: 403 you provided
It’s highly possible that the token you supplied in the WebSocket subprotocol is invalid or expired. Note there are two subprotocols you need to supply, jwt.token.{YOUR_LEDGER_PARTY_TOKEN} and daml.ws.auth.
The “Live Data” view on Project:DABL also use WebSocket connection to show the data, if you can see the data there, it’s very likely your app is using an invalid token.
You can fetch fresh ledger party tokens at Ledger Settings => Party JWT.
Let me know does new token solves it and happy to help more on this. See more details about authentication on DABL here: https://docs.projectdabl.com/api/#authentication
Thanks for the insights…
I noticed in my code, it is still using the same bearer token in the Network communication as my local environment, but the ledger id is now different nxhgy6yk92nxerri
I will regenerate the token and try again
Yes very likely @bartcant
The party token expires in 24 hours by default. For this specific use case check out “service-account” at https://docs.projectdabl.com/api/#authentication whcih provides a long-lived credential for token exchange.