Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct-style websockets with Eio #130

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

patricoferris
Copy link

This PR adds direct-style websockets using eio and cohttp-eio (yet unreleased, but it has been merged in the main branch of mirage/ocaml-cohttp). It is WIP and probably will change, but I thought I would open this PR in case I don't have time to come back to it later.

cc: @bikallem @talex5 who might be able to comment on the core IO implementation a little :))

@patricoferris patricoferris changed the title Eio Direct-style websockets with Eio Sep 2, 2022
Copy link

@talex5 talex5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about web-sockets, but the Eio stuff looks reasonable to me. I suspect you don't need most of the Buf_write.flush calls, though. The buffer gets flushed automatically when you block; flush just makes the caller wait until the data has finished flushing but doesn't speed it up (any more than calling Fiber.yield () would, anyway).

eio/io.ml Show resolved Hide resolved
eio/io.ml Outdated Show resolved Hide resolved
@ryanslade
Copy link

Is there anything holding back this PR for merge? Anything I can perhaps do to help push it over the line?

@patricoferris
Copy link
Author

Is there anything holding back this PR for merge?

Thanks for the interest and offer for help @ryanslade. I would say this PR is blocked on landing a proper release of cohttp-eio. Right now, it is an alpha release and constrains us to eio.0.6 which means we also don't have access to Eio.Buf_read.BE for example. There is some experimentation on what a good HTTP library might look like, see mirage/ocaml-cohttp#969 but I think this implies it's going to be a while before we see a full release of cohttp-eio.

@ushitora-anqou
Copy link
Contributor

Hi. Cohttp 6.0.0~beta1 is out and it has Cohttp_eio.Private.IO module, which implements Cohttp.S.IO. As the Lwt version of ocaml-websocket does, we can feed it to Websocket.Make to get the necessary functions for WS server and client implementations. Personally, I needed an Eio version of a WS client implementation and tried this strategy, which worked just fine. I have left the code here for anyone who needs it.

@Kakadu
Copy link

Kakadu commented Aug 22, 2024

I tried to build this PR with cohttp-eio.6.0.0~alpha2 but stuck with compilation error.

File "ocaml-websocket/eio/websocket_eio.ml", line 61, characters 23-29:
61 |       Cohttp_eio.Body.(Custom f) ) in
                            ^^^^^^
Error: Unbound constructor Custom

I would say this PR is blocked on landing a proper release of cohttp-eio.

@patricoferris have things become better in last year?

@patricoferris
Copy link
Author

Quickly bump to work with cohttp-eio.6.0.0~beta2 should make this work with the beta2 branch of cohttp-eio -- I don't have time to work on this in any detail so please do take the code and run with it :)) Good luck !

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

Successfully merging this pull request may close these issues.

5 participants