ic-websocket-poc
ic-websocket-poc copied to clipboard
How to use it in the forntend?
I am trying to make a call like this
import websocketConnection from "./websocketConnection";
let backend_canister_id = "su63m-yyaaa-aaaaa-aaala-cai";
let gateway_address = "ws://127.0.0.1:8080";
let url = "http://127.0.0.1:4943";
let local_test = true;
let ws = new websocketConnection(backend_canister_id, gateway_address, url, local_test);
await ws.onOpen(async (event) => {
let m = await ws.make_message("test test test test test test test test test test test test " + "-pong")
console.log({m})
})
but I am getting
Uncaught runtime errors:
×
ERROR
Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
at websocketConnection.sendMessage (http://localhost:8080/index.js:21402:19)
at websocketConnection.onOpen (http://localhost:8080/index.js:21438:10)
at async http://localhost:8080/index.js:21142:1
```
# How to make sense of this? how to resolve it?