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

Add Websockets support #1330

Merged
merged 12 commits into from
Oct 30, 2024
Merged

Add Websockets support #1330

merged 12 commits into from
Oct 30, 2024

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Oct 23, 2024

This is a first pass on Websockets support.

features:

  1. TLS and non-TLS connecitons
  2. ring and aws-ls support

what's missing:

  • compression, as tokio_websockets does not support it

next steps:

  • contribute compression to tokio_websockets or add ability to choose between tokio-websockets and tokio-tungsteninte/fastwebsockets.

Signed-off-by: Tomasz Pietrek tomasz@nats.io

pub(crate) struct WebSocketAdapter<T> {
#[pin]
pub(crate) inner: WebSocketStream<T>,
pub(crate) read_buf: BytesMut,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it needs its own buffer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WS libraries returns whole WebSockets messages. Those can be way bigger than the ReadBuf. Is there a way to avoid that buffer easily? :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, had to read the docs, it's a Stream, not a "Stream".

@Jarema Jarema marked this pull request as ready for review October 28, 2024 17:28
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
@Jarema Jarema merged commit e40abcf into main Oct 30, 2024
12 checks passed
@Jarema Jarema deleted the add-ws-support branch October 30, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants