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

Use upstream websocket crate. #16236

Closed
wants to merge 1 commit into from

Conversation

illegalprime
Copy link

@illegalprime illegalprime commented Apr 3, 2017

Recently I've finished another release of the websocket crate, so there's lots of neat stuff to use. I wanted to see how other projects used this library, and I thought this would be a great place to check.

I have some questions on the implementation here that will inform the future design of the websocket crate:

  1. Why is SSL disabled? The only thing I see stopping the use of SSL here is that you are creating a separate receiver and sender for the same connection (and an SSL stream can't be split up like that).
  2. Why split up the stream into a read and writer and not wrap it in a Mutex<> or something?
  3. It seems like all the fetch functions just check and set headers, is it worth keeping the structure or just building a list of headers and setting them in the client builder?

NOTE: this is not ready to be merged, there are some .unwrap() calls and it doesn't set any of the important headers listed later in the file.

ANOTHER NOTE: this websockets release is going to go through some more testing before being published, and is also blocked by hyperium/hyper#1107 being included in a hyper version.

Thanks!


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Apr 3, 2017

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon.

@highfive
Copy link

highfive commented Apr 3, 2017

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/Cargo.toml, components/net/websocket_loader.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 3, 2017
@highfive
Copy link

highfive commented Apr 3, 2017

warning Warning warning

  • These commits modify net code, but no tests are modified. Please consider adding a test!

@SimonSapin
Copy link
Member

CC @avadacatavra, @nox

@nox
Copy link
Contributor

nox commented Apr 3, 2017

Why is SSL disabled? The only thing I see stopping the use of SSL here is that you are creating a separate receiver and sender for the same connection (and an SSL stream can't be split up like that).

That's exactly why, websocket isn't working with latest openssl.

Why split up the stream into a read and writer and not wrap it in a Mutex<> or something?

Because in the current setup, we block on reading in a thread, and we write on a different thread, so the Mutex<> would just deadlock, especially with openssl renegotiations which may require the writer end to need to read.

It seems like all the fetch functions just check and set headers, is it worth keeping the structure or just building a list of headers and setting them in the client builder?

No, we only do a subset of what the websocket RFC allows, so it's better to do the handshake ourselves, especially because I want to merge that code back with fetch::methods in the future.

@nox
Copy link
Contributor

nox commented Apr 3, 2017

Note that I actually tried to update to last websocket before just disabling WSS, I ended up with mio errors.

@nox nox assigned nox and unassigned asajeffrey Apr 3, 2017
@illegalprime
Copy link
Author

@nox so as I understand it you would like to see:

  1. updated openssl dependency (which is there already)
  2. ability to skip the handshake process that comes with the crate (also exists, servo code already uses it)
  3. a way to listen to events from channels and messages from the library at the same time

As far as I know no. 3 doesn't have a good answer yet, since select!() seems like its going away. Is it worth to change these channels to a mio or a tokio channel if the websocket crate gains support for (mio/tokio)?

@nox
Copy link
Contributor

nox commented Apr 3, 2017

As far as I know no. 3 doesn't have a good answer yet, since select!() seems like its going away. Is it worth to change these channels to a mio or a tokio channel if the websocket crate gains support for (mio/tokio)?

Yep!

@nox
Copy link
Contributor

nox commented Apr 3, 2017

@illegalprime I forgot to say it earlier, but thanks for looking at this btw!

@nox nox added S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 15, 2017
@illegalprime
Copy link
Author

I've merged tokio support for websockets, which I'm excited about. I'll be able to get to this soon. The changes in the crate also allow support for SSL in async mode.

@jdm
Copy link
Member

jdm commented Nov 15, 2017

Closing due to inactivity.

@jdm jdm closed this Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants