Skip to content

websocket doesn't work under bun #454

@glorand-harmonicinc

Description

@glorand-harmonicinc

Hi,
If I run the attached example websocket.zip with nodejs it works:

$ node server.js 
Thu Mar 07 2024 09:39:55 GMT+0000 (Coordinated Universal Time) Server is listening on port 8080
Thu Mar 07 2024 09:40:13 GMT+0000 (Coordinated Universal Time) Connection accepted.
Received Message: 397030
Received Message: 10038402
Received Message: 6845227
Received Message: 2955012
Received Message: 5366268
Received Message: 4668963
$ node client.js 
WebSocket Client Connected
Received: '397030'
Received: '10038402'
Received: '6845227'
Received: '2955012'
Received: '5366268'
Received: '4668963'

, but with bun it doesn't:

$ bun server.js 
Thu Mar 07 2024 09:52:10 GMT+0000 (Coordinated Universal Time) Server is listening on port 8080
Thu Mar 07 2024 09:52:15 GMT+0000 (Coordinated Universal Time) Connection accepted.

$ bun client.js

Same result if I also use nodejs for the client part.

Any idea?

Probably not related to this issue but I also tried nodejs for the server and bun for the client and following error occurs (I have added headers dump in the log trace):

$ node server.js 
Thu Mar 07 2024 10:00:12 GMT+0000 (Coordinated Universal Time) Server is listening on port 8080
Thu Mar 07 2024 10:00:17 GMT+0000 (Coordinated Universal Time) Received request for / with headers {"host":"localhost:8080","sec-websocket-key":"ku8AfoxHZGmLPCmPCxoxlQ==","sec-websocket-protocol":"echo-protocol","sec-websocket-version":"13","upgrade":"websocket","connection":"keep-alive","user-agent":"Bun/1.0.30","accept":"*/*"}
$ bun client.js 
Connect Error: Error: Server responded with a non-101 status: 404 Not Found
Response Headers Follow:
date: Thu, 07 Mar 2024 09:54:38 GMT
connection: keep-alive
keep-alive: timeout=5
transfer-encoding: chunked

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions