-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
refactor(gateway, http, lavalink): Switch to tokio-websockets #2239
Conversation
i like this change overall, but users might expect us to use de facto libraries, how much maintenance cost would it add to offer this under a feature flag? |
b697981
to
a596c4d
Compare
Impossible because we would have to make both websocket libraries opt-in to avoid pulling in both for those who do not want to use the other one. It wouldn't be worth the maintainance cost either and would probably require abstracting out a lot of things here in not-so-pretty-ways. In my view we should use whatever we consider superior, the concept of "de facto libraries" is flawed if the libraries are unmaintained or otherwise abandoned, slow or bloated. In my view, if we consider something to be superior, we should use it. |
i dont agree with the de facto libraries are better idea either i was just mentioning what most users would expect from twilight whether we decide twilight isnt for these people is another discussion but unless we jump to that we should ask for user feedback imo |
14cf608
to
7f3ebad
Compare
f586c8b
to
c5709b0
Compare
Signed-off-by: Jens Reidel <[email protected]>
c5709b0
to
9b4b874
Compare
Signed-off-by: Jens Reidel <[email protected]>
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.
I'd also like to see the "The shard is considered disconnected after having received a close frame or encountering a websocket error, but it should only reconnect after the underlying TCP connection is closed by the server (having returned Ok(None)
)." be replaced by:
"The should should only reconnect after the gateway closes the underlying TCP connection."
let mut boundary = [0; 15]; | ||
let mut rng = rand::thread_rng(); | ||
|
||
for value in &mut boundary { | ||
*value = rng.sample(Alphanumeric); | ||
*value = fastrand::alphanumeric() as u8; | ||
} | ||
|
||
boundary |
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.
let mut boundary = [0; 15]; | |
let mut rng = rand::thread_rng(); | |
for value in &mut boundary { | |
*value = rng.sample(Alphanumeric); | |
*value = fastrand::alphanumeric() as u8; | |
} | |
boundary | |
fastrand::u128(..).to_ne_bytes() |
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.
That won't work, boundaries have to be ASCII (Unlike some other parameter values, the values of the charset parameter are NOT case sensitive. The default character set, which must be assumed in the absence of a charset parameter, is US-ASCII)
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.
Looking further into this, I've found conflicting resources on whether the boundary should be randomized or not, and notably I've not found any such mention in an RFC. Do you happen to know? Otherwise it seems silly to randomize the boundary at all.
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.
Boubdaries can be arbitrary, as long as they're ASCII. Ideally they shouldn't appear in the form content, but that's all really. We could get away with using a static boundary.
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.
Let's leave this as is for now. The issue is tracked in #2278
Signed-off-by: Jens Reidel <[email protected]>
// Abnormal closure without close frame exchange. | ||
self.disconnect(CloseInitiator::None); | ||
self.reconnect(None, 0).await?; |
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.
Actually, we do need to return something here to indicate upstream that the shard's closing. Again, let's leave this as is but remember to check back on this prior to a release. I plan on rewriting large parts of the internals of Shard
(cancel safety) during which I'll fix this too.
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.
Let's get this merged into next very soon then so we can start refactoring the shard internals
Signed-off-by: Jens Reidel <[email protected]>
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.
Looks good, if we run into any issues we should be able to resolve them before a release.
This switches our websocket library from tokio-tungstenite to tokio-websockets.
Why?
rustls-webpki-roots
enabled sees this dependency drop when using this PR:TlsConnector
logic, since tokio-websockets has this in-builtWhy not?
Notes
Currently using a git dependency on tokio-websockets because I've added a few changes for easier integration with twilight that will require a new minor releaseI released 0.4.0 nowThe entire twilight integration is completely untestedI've verified that the gateway implementation runs shards properly for a long time (with several resumes), lavalink needs testingrand
since it is a bit big for our uses and switched tofastrand
because tokio-websockets supports it and uses it by default. I could revert that for now if desired.TODO
Need to figure how to make cargo-hack skip theJust always enable sha1_smol--no-default-features
case and instead enable theno-tls
feature for that