Skip to content

Conversation

dcrck
Copy link
Contributor

@dcrck dcrck commented Mar 22, 2025

Cleans up #967 by adding some tests for the isutf8 changes and websocket handshake, removing unused variables, and fixing the failing autobahn-testsuite test.

This also adds a basic websocket echo server to the redbean-tester at /ws.

I'd like to add more tests but I don't know the best way to do so:

  • get raw socket communication working in redbean_test.c, or
  • create a ws_test.lua file to run the autobahn-testsuite against the server.

Advice and feedback is appreciated. I am new to sockets programming. I'm in the Discord all the time, or can respond to questions/feeback here if that's preferable. 🙂

Closes #439

To run more detailed tests (once o//test/tool/net/redbean-tester is running):

docker run -it --rm -v "${PWD}/config:/config" -v "${PWD}/reports:/reports" -p 9001:9001 --network host crossbario/autobahn-testsuite wstest -m fuzzingclient -s /config/fuzzingclient.json

config/fuzzingclient.json should contain:

{
  "outdir": "./reports/servers",
  "servers": [
    {
      "url": "ws://127.0.0.1:8080/ws"
    }
  ],
  "cases": ["*"],
  "exclude-cases": [],
  "exclude-agent-cases": {}
}

Results will then be available at ${PWD}/reports/servers/index.html

@pkulchenko
Copy link
Collaborator

pkulchenko commented Mar 22, 2025

@dcrck, thank you for picking up this work. I'm confused a bit: is this PR a mix of commits from #967 and tests/cleanup that you added? Shouldn't the original commits retain all their metadata with your changes layered on top of them?

@dcrck
Copy link
Contributor Author

dcrck commented Mar 22, 2025

I'm confused a bit: is this PR a mix of commits from #967 and tests/cleanup that you added? Shouldn't the original commits retain all their metadata with your changes layered on top of them?

That would probably be a better way to do it, but I didn't have access to the original repository containing the work so I just copied over all the changes to my repository. I can re-organize it so it contains their changes.

@dcrck
Copy link
Contributor Author

dcrck commented Mar 22, 2025

@pkulchenko should be updated now

@pkulchenko
Copy link
Collaborator

Looks good; thank you for incorporating those changes!

@jart, do you have a copyright assignment from @wingdeans (from #967)?

@dcrck
Copy link
Contributor Author

dcrck commented Apr 19, 2025

@jart it's been about a month since I opened this PR, can you please check on @wingdeans' copyright assignment (should be #967 )? Thank you!

@jart
Copy link
Owner

jart commented May 5, 2025

Sure I'll take a look this week.

@atgreen
Copy link

atgreen commented Aug 19, 2025

Any updates on this feature? I would love to see it merged. Thank you!

@javajosh
Copy link

Hi there. I was interested in adding websockets to redbean in 2022 (#439). Now that this PR landed, I have questions that aren't answered in the readme. (In fact, the readme still states that websockets "may be added in the future" FYI. Given the forking nature of redbean as a webserver, how does this work with websockets (ws)? If inbound ws are each handled by a different process, then how do they communicate with each other? If a single process is handling all ws, how does one program their interaction? Is there a C or Lua API for doing that? Are there any benchmarks or resource-usage statistics available? I'd be happy to pitch in, especially for the last one. I'm no Kyle Kingsbury but I can test a thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Expect redbean to support websocket
6 participants