redbean: add websocket support
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.luafile to run theautobahn-testsuiteagainst 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. :slightly_smiling_face:
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
@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?
I'm confused a bit: is this PR a mix of commits from https://github.com/jart/cosmopolitan/pull/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.
@pkulchenko should be updated now
Looks good; thank you for incorporating those changes!
@jart, do you have a copyright assignment from @wingdeans (from #967)?
@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!
Sure I'll take a look this week.
Any updates on this feature? I would love to see it merged. Thank you!
Hi there. I was interested in adding websockets to redbean in 2022 (https://github.com/jart/cosmopolitan/issues/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.