rust-websocket | A WebSocket (RFC6455) library written in Rust | Websocket library
kandi X-RAY | rust-websocket Summary
kandi X-RAY | rust-websocket Summary
Rust-WebSocket
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rust-websocket
rust-websocket Key Features
rust-websocket Examples and Code Snippets
Community Discussions
Trending Discussions on rust-websocket
QUESTION
I'm trying to make a web server in Rust for a simple browser game. I want the server to be able to deliver pages through HTTPS, but also be able to communicate through WebSockets. I'm planning to put this server on Heroku, but since they only allow one port per application I have to make the WebSocket server operate on the same port as the other HTTPS code.
It seems like this is possible with crates like rust-websocket
, but that crate uses an outdated version of hyper
and seems to be no longer maintained. The crate tokio_tungstenite
is much more up to date.
The problem is that both hyper
and tungstenite
have their own implementation of the HTTP protocol that WebSockets operate over with no way to convert between the two. This means that once an HTTPS request has been parsed by either hyper
or tungstenite
there is no way to continue the processing by the other part, so you can't really try to connect the WebSocket and match on an error in tungstenite
and process it by hyper
, nor can you parse the request by hyper
and check if it's a WebSocket request and send it over to tungstenite
. Is there any way to resolve this problem?
ANSWER
Answered 2018-Nov-02 at 13:01I think it should be possible to do that, the tungstenite
and tokio-tungstenite
allow you to specify custom headers (there are helpers functions for that, prefixed with hdr
), so depending on the hyper
version you use, if you can convert a request to some form, when the headers can be extracted, you can pass them to tungstenite
.
You might also want to try warp
crate, it's built on top of hyper
and it uses tungstenite
under the hood for the websocket support, so if you want to write your own version of warp
, you can take a look at the source code (the source code may contain hints on how to use hyper
and tungstenite
together).
QUESTION
I'm trying to wrap my head around futures in Rust but I am confused by this code which is supposed to send messages arriving at rx
to sink
:
ANSWER
Answered 2018-Feb-12 at 05:49QUESTION
I want to write a webserver using Rust, Hyper and websocket-rs. The webserver must be able to handle http requests AND websocket requests on the same port. I used the official sample (async-server.rs
: https://github.com/cyderize/rust-websocket/blob/master/examples/async-server.rs) and tried to modify it. My idea was to change the error handling. If the client's request is a simple http request then do not return an error, but spawn a future which handles the request instead.
Based on another SO question (How do I handle an error when using rust-websocket so that only that connection fails and not the entire program?) I changed the error handling from the sample.
This is the old code:
...ANSWER
Answered 2017-Aug-22 at 18:47There seems to be some docs on this in the rust-websocket documentation here
Pasting from the docs:
QUESTION
I am writing a Phoenix client library for Rust, taking advantage of the async websocket client from rust-websockets. Right now I am having trouble figuring out how to pass callback functions in to the thread that is handling the websocket traffic. I have a simplified struct:
...ANSWER
Answered 2017-Jul-25 at 19:29After doing some more research I realized that I just had to modify Option>
to be Option>
and copy that around my code to everywhere that the callback might be set. Learning more about trait objects!
QUESTION
I am writing a websocket server in Rust using rust-websocket and its Tokio-based async system. I can serve clients just fine, however, I can not figure out how to share mutable state between the clients. Here is some (partial) code demonstrating this issue:
...ANSWER
Answered 2017-Jul-03 at 19:11QUESTION
I'm trying to use error-chain with the websocket crate, but running into an issue that I'm not sure how to resolve. WsUpgrade::accept
has the following signature:
ANSWER
Answered 2017-May-15 at 02:09A simple solution would be to introduce a type alias:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rust-websocket
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page