Closed vi closed 5 years ago
Are you by the way interested in #222 (and in general in migration away from hyper 0.10)?
@vi why move from hyper 0.10?
Because of it is non-last version of hyper, making it auto-deprecated.
For example, Debian package suites are supposed to contain only one package per crate.
If Hyper 0.10 continues to live, it should be published with some new separate name.
I will help if you need to.
What exactly do you want to achieve? What is your plan?
The plan is mostly this:
websocket-lowlevel
;websocket-lowlevel
, either using hyper 0.12
or using something else.websocat
(which is why I got involved in rust-websocket
project in the first place), removing obstacle for publishing to Debian.websocket
as officially deprecated; maybe rewire it to depend on some successor of hyper 0.10
if there is any.I'm not sure about this although.
So looks like you want to move all core parts and create some kind of https://github.com/snapview/tungstenite-rs/tree/master/src ?
tungstenite
? I haven't yet considered it. It seems to be relatively new project.
Can it do async? How does it compare to rust-websocket
?
Can it do async? How does it compare to rust-websocket?
I don't know, but I have just discovered it in https://github.com/seanmonstar/warp/blob/master/src/filters/ws.rs when googled how to set up hyper with websockets.
Is this change still being considered?
I'd like to update websockets to the new futures api, but doing that would conflict with this change heavily.
Yes, I'm going to base websocat 2.0
on it (in order to drop hyper 0.10 dependency).
You can look at split_in_two
branch and point a pull request to there.
But expect the pull request to hang around for rather long time. Maybe it would make sense to release it to crates.io with other name (like websocket-async
+ websocket-async-ll
) in meantime. README
of this project may include link to the fork.
Is there any way I can help with getting it merged?
Is there any way I can help with getting it merged?
Review it and state opinions:
I'm curious, why not just have the crate use a newer version of hyper? After reading the comments here, it seems like the motivation for the split is remaining on hyper 0.10, but no one says why.
why not just have the crate use a newer version of hyper?
Hyper 0.12 is drastically different from 0.10. Also it does not support non-async at all. It may be easier to rewrite websocket
entirely based on hyper 0.12
and websocket-lowlevel
rather than trying to migrate it evolutionally.
Note, reqwest implements both sync and async apis on top of hyper's async api's. That seems reasonable?
That seems reasonable?
You have to have an executor (futures/tokio/romio) to block on a async future. And this library is executor-free.
hyper depends on tokio, tokio has an executor, so a sync version of websockets can be implemented on top of hyper by blocking on the tokio executor?
Hyper 0.12 is drastically different from 0.10. Also it does not support non-async at all. I
@vi Are you sure?
Is there any way I can help with getting it merged?
Review it and state opinions.
So, do you have any opinions? Shall websocket-lowlevel
+ websocket
be published or there are blockers?
I have said it before on tungstenite and tide, but I think what would make sense for the rust websocket ecosystem is to have a separate websocket_handshake crate that everyone can agree on.
It would deal with http handshake and websocket crates could take it from when the handshake is finished. It could rely just on http crate, take in something that implements std::Read + std::Write and return that once the handshake is complete. It would deal with protocols, extensions, http2 etc.
All web frameworks could depend on it for the handshake before switching to a websocket phase 2 crate, or implementing their own phase 2 API (like warp)
All websocket crates could depend on it for standalone websocket server.
This would reduce all of the duplicated work, as well as decrease risk of bugs and security vulnerabilities and improve interoperability.
@hyyking , Do you have an opinion about this pull request? Shall I release it already (as 0.24.0
or 0.25.0
) or something needs to be addressed before that?
Rust wise LGTM, I don't like the name websocket-lowlevel
(maybe websocket-basis/base
). I think it's good for now.
But like said above we could split the crate even more it would make feature developping much easier (rn it's hard to differentiate what needs what). Maybe have a codec workspace for async and a true base crate with handshake/frame like said above.
@hyyking Which names do you suggest for:
rust-websocket
part that does not depend on any HTTP or async library. Just encoding/decoding messages, base64, key, some type definitions, etc.rust-websocket
part that can wrap an async connection to provide a WebSocket message-based async connection, but without negotiation / http upgrade part. That would depend on futures
.rust-websocket
part that depends on legacy outdated hyper 0.10
library? Shall it provide fully-fledged WebSocket experience or just HTTP upgrade without the channel itself?I believe the project should be split in 3 parts (I'm ok with helping btw)
rust-websocket-encoding
(ws-encoding
workspace) for message encodingrust-websocket-upgrade
(ws-upgrade
workspace) for the http upgrade protocol (deps: hyper
and ws-encoding
)rust-websocket
should provide work-ready sockets with sync/async/tls features like it does right nowShall special effort be dedicated to prevent / minimize API breakage during the split? Is API preservation worth complicating the error handling?
Shall special effort be dedicated to prevent / minimize API breakage during the split? Is API preservation worth complicating the error handling?
That's up to you, if we achieve the changes above it's a major release-worthy so breaking changes may occur. Current API is fine imho but maybe things will be uncovered during the split. If these changes go through we should be able to handle errors in a clearer way but that should be another release I think.
rust-websocket still depends on legacy
hyper 0.10
.This may be the first step to migrate it to something else.