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

Feature Request: Support for WebSocket over Unix Domain Sockets #2918

Open
zhengfeihe opened this issue Aug 10, 2024 · 6 comments
Open

Feature Request: Support for WebSocket over Unix Domain Sockets #2918

zhengfeihe opened this issue Aug 10, 2024 · 6 comments
Assignees
Labels
Example An issue which concerns the examples

Comments

@zhengfeihe
Copy link

zhengfeihe commented Aug 10, 2024

Hi Maintainers,

I have found, support for using custom external sockets is not available in beast, as noted in this issue. Specifically, I encountered this limitation when trying to use WebSocket over Unix sockets. This seems to be a missing feature in many C++ WebSocket libraries. There were also issues related to using WebSockets over Unix domain sockets in websocketpp, but it appears to be unmaintained.

Building WebSocket communication over Unix domain sockets is supported in some packages for other languages. For example, in Python's websocket-client package, you can configure a Unix domain socket when creating client connections: websocket-client.

Do you think this is a feature that could be added to Beast? If so, would it be acceptable for me to work on this? It may take some time for me to implement.

Best,
Zhengfei

@ashtum
Copy link
Collaborator

ashtum commented Aug 10, 2024

You can easily use a different socket type for the underlying stream of websocket::stream:

using ws_stream_t = beast::websocket::stream<asio::local::stream_protocol::socket>;

The websocket::stream::next_layer function gives you access to the underlying stream, allowing you to perform the connect operation. Alternatively, you can move an already connected socket into the websocket stream constructor.

@vinniefalco
Copy link
Member

We should provide a working example program for this since it keeps coming up.

@zhengfeihe
Copy link
Author

Thanks for your reply and explanation! I will close the issue.

@ashtum ashtum self-assigned this Aug 11, 2024
@ashtum ashtum added this to the Boost 1.87 beta milestone Aug 11, 2024
@ashtum ashtum reopened this Aug 12, 2024
@ashtum ashtum added the Example An issue which concerns the examples label Aug 12, 2024
@savely-krasovsky
Copy link

I would also add an example with Windows Named Pipe. I know, Windows supports UNIX domain sockets since Windows 10, but named pipes has better Windows Security support (you can run named pipe with own security descriptor).

@vinniefalco
Copy link
Member

Does asio have a windows named pipe implementation that meets the stream requirements?

@savely-krasovsky
Copy link

@vinniefalco yes: https://www.boost.org/doc/libs/1_86_0/doc/html/boost_asio/overview/windows/stream_handle.html
I tried it with http client, works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Example An issue which concerns the examples
Projects
None yet
Development

No branches or pull requests

4 participants