Is it possible to use WebSocket clients in workers?

Is it possible to use new WebSocket(url) and connect to an external websocket server with a worker?
1 Reply
Nenc
NencOP6mo ago
ok, ik now
let resp = await fetch('https://<url>', {
headers: {
Upgrade: 'websocket',
},
});

let ws = resp.webSocket;
if (!ws) {
throw new Error("server didn't accept WebSocket");
}

ws.accept();
let resp = await fetch('https://<url>', {
headers: {
Upgrade: 'websocket',
},
});

let ws = resp.webSocket;
if (!ws) {
throw new Error("server didn't accept WebSocket");
}

ws.accept();
from https://discord.com/channels/595317990191398933/967783711955365899/997600406182035496
Want results from more Discord servers?
Add your server