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
Simple WebScoket connection (ws.js) to a weboscket server (wss.js), sending over binary data from bun.lockb file in chunks.
// ws.jsimportfsfrom"fs";constURL="https://bun-faulty-ws.up.railway.app/";// or any remote urlconstws=newWebSocket(URL);ws.addEventListener("open",async()=>{console.log("connection opened");ws.addEventListener("error",(e)=>console.error("connection error",e));ws.addEventListener("close",(e)=>console.log("connection closed:",e.reason),);ws.addEventListener("message",(e)=>{console.log("message",e.data);});// read from file and send to wssconstfileStream=fs.createReadStream("bun.lockb");forawait(constchunkoffileStream){console.log("sending chunk of size",chunk.length);ws.send(chunk);}});
And here is the code for my remove weboscket server. Server is deployed (i used railway.app in this case). When running server locally it works as expected, but not if the server is on a different network.
// wss.jsimport{WebSocketServer}from"ws";constport=Number(process.env.PORT??3000);constwss=newWebSocketServer({ port });wss.on("connection",function(socket){console.log("client connected");socket.on("message",function(message){// no message when using client connected via bun, but ok if client is nodeconsole.log("message from client",message.length);});socket.on("close",function(){console.log("client disconnected");});});console.log(`WebSocket server is running on port ${port}`);
What is the expected behavior?
binary data chunks sent over to remote websockets server
What do you see instead?
no data is sent to remote server when using bun, but ok if using node (v22)
What version of Bun is running?
1.1.8+89d25807f
What platform is your computer?
Darwin 23.1.0 arm64 arm
What steps can reproduce the bug?
Simple WebScoket connection (ws.js) to a weboscket server (wss.js), sending over binary data from
bun.lockb
file in chunks.And here is the code for my remove weboscket server. Server is deployed (i used railway.app in this case). When running server locally it works as expected, but not if the server is on a different network.
What is the expected behavior?
binary data chunks sent over to remote websockets server
What do you see instead?
no data is sent to remote server when using
bun
, but ok if usingnode
(v22)Additional information
here is the repo with code and description of the issue https://github.com/kynnyhsap/bun-faulty-webosckets
important to say that it works when server launched locally, but not when it is a remote wss.
The text was updated successfully, but these errors were encountered: