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
When using Bun.serve to create a websocket server and you enable TLS, the server is not able to accept any request until you make a normal http request to let the upgrade fail or you use firefox first.
This is a normal bun serve from the example.
I have enable TLS with correct TLS and all the domains are correct (No CORS issues).
Bun.serve({
port: 8080,
fetch(req: any, server: any) {
console.log("Fetch");
if (server.upgrade(req)) {
return; // do not return a Response
}
return new Response("Upgrade failed", { status: 500 });
},
tls: useSecure
? {
cert: Bun.file(cert),
key: Bun.file(key),
ca: [Bun.file(chain)],
}
: null,
....
When running with no useSecure and you connect via ws:// protocol everything is ok.
But when you connect via wss:// protcol, the connection fail without any error and you are not able to see even the 'fetch' log.
BUT if you open chrome at wss://ip:port you will see, oblivusly, the "Upgrade failed" error.
From this time on, the websocket server works correctly and the applications is able to connect without issues.
The same is if you use FireFox, it just works on it and after the first connection also edge and chrome starts to work.
What is the expected behavior?
It should always connect correctly with all browsers the first time.
What do you see instead?
Connection failed on chrome and edge until you do a valid http request that fails the upgrade or you use firefox fist.
Additional information
No response
The text was updated successfully, but these errors were encountered:
m-valvano-zakeke
changed the title
WSS chromimu works only after a first upgrade fail or connected with firefox first
WSS chromium works only after a first upgrade fail or connected with firefox first
May 19, 2024
What version of Bun is running?
1.1.0
What platform is your computer?
Linux 5.10.0-28-cloud-amd64 x86_64 unknown
What steps can reproduce the bug?
When using Bun.serve to create a websocket server and you enable TLS, the server is not able to accept any request until you make a normal http request to let the upgrade fail or you use firefox first.
This is a normal bun serve from the example.
I have enable TLS with correct TLS and all the domains are correct (No CORS issues).
When running with no useSecure and you connect via ws:// protocol everything is ok.
But when you connect via wss:// protcol, the connection fail without any error and you are not able to see even the 'fetch' log.
BUT if you open chrome at wss://ip:port you will see, oblivusly, the "Upgrade failed" error.
From this time on, the websocket server works correctly and the applications is able to connect without issues.
The same is if you use FireFox, it just works on it and after the first connection also edge and chrome starts to work.
What is the expected behavior?
It should always connect correctly with all browsers the first time.
What do you see instead?
Connection failed on chrome and edge until you do a valid http request that fails the upgrade or you use firefox fist.
Additional information
No response
The text was updated successfully, but these errors were encountered: