You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is really strange, i have tried to test it down.
I observed, see also the comments in the test file, that when you try to push messages via websocket.send using a normal ws connection, all works fine, also when you observe the websocket events for a ping, or a string, all works.
But when you use a wss connection, the messages will not be pushed.
The problem seems to be the observing of the websocket events, if you remove/deactive it - all works, and the messages will be pushed to the client.
Also, if u send a manual event to the server via a client, the not pushed messages, will then be pushed - seems the websocket server needs a trigger to actually push it.
When u log the websocket connection you can see, that the messages are hanging in the message queue. :(
Expected Behaviour
Websocket messages will be pushed to client, when using a wss connection.
Actual Behaviour
No messages will be pushed.
Steps to Reproduce
Create a file named mod.ts with the following content:
// ! Problem: When u use https message 2 and 3 will not be pushed, when the for loop is activated.constuseHttps=true;// change meconstobserveWsEvents=true;// the problem seems to be here, change it to false when u use https and it works!asyncfunctionhandleWs(sock: WebSocket){console.info("socket connected!");awaitsock.send("message 1");setTimeout(async()=>{awaitsock.send("message 2");constcevent=newCustomEvent("cevent");globalThis.dispatchEvent(cevent);},1000*5);globalThis.addEventListener("cevent",async(event)=>{awaitsock.send("message 3");});if(observeWsEvents){forawait(consteventofsock){if(typeofevent==="string"){console.log(`ws:Text ${event}`);awaitsock.send(event);}}}}constport=5000;consthttpServer=useHttps
? serveTLS({
port,certFile: "./cert/localhost.crt",keyFile: "./cert/localhost.key",})
: serve({ port });console.info(`${useHttps ? "https" : "http"} server is running on :${port}`);forawait(constreqofhttpServer){try{constws=awaitacceptWebSocket({conn: req.conn,bufReader: req.r,bufWriter: req.w,headers: req.headers,});console.info(`websocket server is running on :${port}`);awaithandleWs(ws);}catch(e){console.error(`failed to accept websocket: ${e}`);}}
Run it with deno run --unstable --allow-read --allow-net --allow-env --lock-write --lock lock.json mod.ts
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This is really strange, i have tried to test it down.
I observed, see also the comments in the test file, that when you try to push messages via
websocket.send
using a normal ws connection, all works fine, also when you observe the websocket events for a ping, or a string, all works.But when you use a wss connection, the messages will not be pushed.
The problem seems to be the observing of the websocket events, if you remove/deactive it - all works, and the messages will be pushed to the client.
Also, if u send a manual event to the server via a client, the not pushed messages, will then be pushed - seems the websocket server needs a trigger to actually push it.
When u log the websocket connection you can see, that the messages are hanging in the message queue. :(
Expected Behaviour
Websocket messages will be pushed to client, when using a wss connection.
Actual Behaviour
No messages will be pushed.
Steps to Reproduce
mod.ts
with the following content:deno run --unstable --allow-read --allow-net --allow-env --lock-write --lock lock.json mod.ts
Using
The text was updated successfully, but these errors were encountered: