-
Notifications
You must be signed in to change notification settings - Fork 233
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
Conversion to tokio 0.2 #68
Conversation
currently hung up on tokio-dns, looks like the future it returns isn't correct, |
Have you filed an issue at tokio-dns to resolve the blocker? |
Master has the required updates, so using that to keep moving forward.
…On Tue, Sep 10, 2019, 7:07 AM Naja Melan ***@***.***> wrote:
Have you filed an issue at tokio-dns to resolve the blocker?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#68?email_source=notifications&email_token=AALIKFGWLR6I3CVQD2WTRKLQI6L2TA5CNFSM4IVBHKW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6LAOPA#issuecomment-529925948>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALIKFEKHTFMHI4M7MJYOK3QI6L2TANCNFSM4IVBHKWQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just asking some questions, I haven't fully reviewed everything.
I do feel this lacks integration testing, verifying every possible scenario, but then again, tokio-tungstenite didn't have those before either.
Will look at add at least a couple more once I get something that seems like it might work. |
@najamelan @application-developer-DA Everything compiling, existing tests passing. Examples upgraded as well. Will be seeing what I can come up with for tests. |
This doesn't build without the tls feature. In particular here: https://github.com/dbcfd/tungstenite-rs/blob/expose-machine/src/client.rs#L49
|
@CryZe This was actually an issue in tungstenite and is fixed in snapview/tungstenite-rs#73. cargo update and this branch should build now. |
Nice, another issue I ran into was that the pin-project |
Matching hyper for now, since one of the reasons for this work was to use it in warp. |
If I'm sending two messages before trying to receive any I get:
|
@CryZe Added a test which reproduces this behavior, attempting to determine cause and fix it. |
The multiple write failure is due to tungstenite write_message calling flush. This means that Sink cannot be used for send, since it does not include a context. |
That seems to have fixed the bug for me :) |
Is there a reason this doesn't use Sink for sending messages? |
@CryZe Sink cannot be used because tungstenite write_message is also calling flush. Sink write does not provide a context, so no context is present when write_message then calls flush. One possibility is to separate the the write and flush into separate functions in tungstenite (that write_message uses), so then we could implement Sink in tokio-tungstenite. |
Async/await is now available on Beta, so we don't even need nightly anymore! 🎉 https://blog.rust-lang.org/2019/09/30/Async-await-hits-beta.html |
Yeah looks like tokio and futures have released versions that are compatible with the beta, so I'd appreciate if this PR would be updated to those versions as well. I did the changes locally here: CryZe@d4e5872 |
Just wanted to say I'm pretty excited about this PR, I've been trying the most recent version out for a side project the last few days. It's just very smooth integration, I'd say currently this is shaping up to become the go-to for anyone building a websocket based application using async/await. The only issue I've noticed so far is due to not implementing |
Can someone point me to a way to read and write to the same Websocket with this implementation without |
It is doable via |
I just discovered that it does work when I remove my call to I also can't use Seems like this is one of the applications where the |
@skaufhold I will look about adding a split method to this, so that Sink is not required. @anlumo It will look something like this
You can also do something like
The examples (especially autobahn) show this off better https://github.com/snapview/tokio-tungstenite/pull/68/files#diff-9da84c2001004ed41d861e7b1fc0850fR37 |
I use the following workaround: let (mut ws_stream, _) = match connect_async(...).await {
Ok(x) => x,
Err(e) => {}
};
let mut heartbeat = Interval::new(Duration::from_secs(3));
'inner: loop {
let either1 = select(receive_channel.next(), select(heartbeat.next(), ws_stream.next())).await;
match either1 {
Either::Left((msg, _)) => {
// received message via channel, process it
}
Either::Right((either2, _)) => {
match either2 {
Either::Left(_) => {
// heartbeat, do whatever
}
Either::Right((msg, _)) => {
// websocket message received, process it
}
}
}
}
} |
Hello @dbcfd , I'm fiddling with the server and client examples. |
What's the status of this? |
I believe that the acceptance of this PR was blocked on the next stable hyper release? That's just happened ( https://seanmonstar.com/post/189594157852/hyper-v013 ), so are there any remaining issues here? |
This reverts commit dd9cad6.
@bstrie Nope :D |
@application-developer-DA ready for review/merge |
@@ -21,7 +21,7 @@ stream = [] | |||
log = "0.4" | |||
futures = "0.3" | |||
pin-project = "0.4" | |||
tokio = "0.2" | |||
tokio = { version = "0.2", default-features = false, features = ["io-util"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but tokio's Cargo.toml has:
# Include nothing by default
default = []
so default-features = false
is a no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's assuming they won't add some. But I guess that's somewhat unlikely.
@application-developer-DA Any chance this could be merged ASAP? |
What, if anything, could be done to progress this? |
I would suspect that the maintainers are reasonably predisposed during the holidays, although I suppose it wouldn't hurt to ping @agalakhov as well. |
I'll check this during the holidays. |
@application-developer-DA while examples are definitely important, I strongly suggest merging this as is if it works. There is too much downstream blocked from upgrading to Tokio 0.2 because this PR has not been merged yet. |
Checked this partially. This pull request requires more cleanup to be merged. I'm working on it. Sorry, it can't be merged in its current state. |
@agalakhov If it's in the working state it could be possible to merge as is and keep iterating in subsequent commits. You can slap an |
I have to check for some potential security and stability issues first. Especially handshake code has to be carefully checked. Now it is much better than initially (no more |
Ok, I checked this. While |
Convert to tokio 0.2