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

websockets initial messages delayed multiple seconds #1961

Closed
1 task done
rukai opened this issue Apr 25, 2023 · 4 comments
Closed
1 task done

websockets initial messages delayed multiple seconds #1961

rukai opened this issue Apr 25, 2023 · 4 comments

Comments

@rukai
Copy link

rukai commented Apr 25, 2023

  • I have looked for existing issues (including closed) about this

Bug Report

Version

axum 0.6 and latest git

Platform

Linux memes 6.2.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 20 Apr 2023 16:11:55 +0000 x86_64 GNU/Linux

Crates

axum

Description

Please refer to this repo that reproduces the issues https://github.com/rukai/axum/tree/websockets_bug_report
Run
axum/examples/websockets/src> cargo run --bin example-websockets
and
axum/examples/websockets/src> cargo run --bin example-client

I create a websocket handler on the server which responds with many messages for each message that the client sends it.

The server sends each message 1 second apart, but the client receives the first 3 messages all at once after 3 seconds. From that point things proceed reasonably
Instead of this behavior I expect the initial messages to arrive immediately after being sent.

In my application I had these much more severe scenarios occur:

  • no messages arriving until the server closes the connection after about 30s
  • no messages arriving until the client has sent 14 messages over about 14s

but I couldnt recreate these severe cases in a simple scenario.
My application is running over a network which may be making the issue worse than the simple localhost test in the reproduced example.

Possibly this is a tungstenite issue, but figured I'd start by reporting it here.

@davidpdrsn
Copy link
Member

Either I don't understand what you mean or I cannot reproduce it.

This is what I see

2023-04-25_15-41-39.mov

@rukai
Copy link
Author

rukai commented Apr 25, 2023

Looks like you have main checked out instead of the branch I linked.
These are the changes to the example: f1cbd6b

@davidpdrsn
Copy link
Member

Ah I see. I just git cloned your fork, but I see it now. I tried setting no_delay on the tcp stream but that didn't change it.

It's most likely a thing with tungstenite though. Axum's web sockets are a very thin wrapper around tungstenite.

I'll close this for now but feel free to ask follow up questions.

@rukai
Copy link
Author

rukai commented Apr 26, 2023

Thankyou for at least confirming you can reproduce it, I've now reproduced it without axum involved and will take it up with the tungstenite project.

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

No branches or pull requests

2 participants