capnproto / capnproto-rust

Cap'n Proto for Rust
MIT License
2.06k stars 222 forks source link

capnp_rpc does not work on monoio #495

Closed SteveLauC closed 5 months ago

SteveLauC commented 6 months ago

Hi:)

I am playing the hello-world example on monoio (A runtime that is based on io_uring), but both server and client sides block, and from my observation, .awaiting RpcSystem won't finish and simply blocks, so I come here to seek some help:>

You can find the code here, in README, I documented the changes that I have made to the original code and some observations that I found while debugging the program, hope they will help a bit.

dwrensha commented 6 months ago

Interesting. What happens if you try a simpler example that uses only capnp-futures (and no RPC)? Does that hit a similar problem?

SteveLauC commented 6 months ago

Hi! Thanks for your help and response!

I wrote a simple TCP server that would echo the message received from client using capnp-futures and monoio (repo), and it looks like it is working pretty well:

$ cargo b
$ ./target/debug/capnp_futures_monoio server 127.0.0.1:8100
INFO: server listening on 127.0.0.1:8100
$ ./target/debug/capnp_futures_monoio client 127.0.0.1:8100 first_message
INFO: client message sent
INFO: client received: 'Server: copy that'
$ ./target/debug/capnp_futures_monoio server 127.0.0.1:8100
INFO: server listening on 127.0.0.1:8100
INFO: Server received: 'first_message'
INFO: Server response sent
SteveLauC commented 5 months ago

Well, it turns out that it WORKS on monoio!

It blocks in my repo because I .awaited the RpcSystem, which should not be done, so this issue does not exist, closing.

dwrensha commented 5 months ago

Ah, right. The RpcSystem needs to be driven, but if you await it in the main task then it will never finish. You need to spawn a new task for it.