need help with client + server in single threaded runtime #213
Unanswered
JimitSoni18
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Thank you for bringing this. I was able to reproduce it. From network analysis, it seems there is a difference in the I/O driver between single and multi-thread runtime. I did not have time yet to look deep into this. I will do it asap |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a test that goes like this:
this test builds a multi threaded runtime in tokio, creates a server future and a client future, joins the futures, sends a message from the client, reads in the server, asserts and exits.
this test runs without issues.
but when i use a single threaded runtime using
new_current_thread
instead ofnew_multi_thread
or by annotating the test withtokio::test
(which uses thecurrent_thread
runtime) and removing the runtime builder code, and then run the test, the test starts failing.i try to spawn the async blocks using tokio::spawn both server and client, and joining the returned JoinHandles, instead of directly joining, the test still fails.
The error is as follows:
which means that either the server or the client drops the connection before the message is sent.
i add printlns at the end and start of the client and server async blocks and here is the output:
This shows that the client writes the message and exits dropping the connection, and the server calls unwrap without reading the message.
but if this is the case, then it should not work in multi threaded runtime as well, - as the client should drop the connection as soon as it writes the message, so i switch to multi threaded, with the print statements in place, and run it.
Here is the output:
Similar to the current thread runtime, the client writes and then exits, but the server is still able to read the message after the client has exited.
This makes me wonder - What goes wrong in the
current_thread
runtime?Note: The functions
read_message
andwrite_message
are implemented in this repository, in theMessageReader
andMessageWriter
traits.Beta Was this translation helpful? Give feedback.
All reactions