#websocket server auto closed when I transfer a file about 15M
1 messages · Page 1 of 1 (latest)
any update on this?
bun.d.ts — (L1882-L1882)
maxPayloadLength?: number;
you'll want to set that number higher
I will definitely try this . thanks , before that I have change most of my code to send big message through http multipart/formdata
is there a maximum limit on this setting? for example 100M?
Hi, just tested , problem still there, server close connection when I upload a 20M file. Shall I config it correctly
//bun websocket server
const server = Bun.serve({
maxPayloadLength: 50 * 1024 * 1204,
port: port,
fetch(req, server) {
const success = server.upgrade(req);
if (success) {
// Bun automatically returns a 101 Switching Protocols
// if the upgrade succeeds
return undefined;
}
// handle HTTP request normally
return new Response("Hello world!");
},
websocket: getWebsocketHandler(),
});
maxPayloadLength goes under websocket
I suggest installing the bun-types npm package
so your text editor tells you more about what APIs are supported
problem solved ,thanks a lot! BTW, how to use this bun-types package. I did not see any changes in vscode
and additional question is compare to send big message through http multipart/formdata , is it faster or slower using websocket ?
Read the docs https://bun.sh/docs/typescript
Kinda depends on latency requirements, web sockets might be good option if it needs to be live, though, they consume more resources in idle, whereas http needs to connect first. As always with performance, do your own testing for your specific use case and then decide.