-
I have a project which needs to have both a http server and a tcp server. So I choose actix-web and tokio(version 0.3.1).
It compiles, but it panic at runtime:
If I use the same tokio version as what actix-web depends(which is 0.2.x), it's ok. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Tokio 0.2 and 0.3 are not directly compatible, but there is a compatibility layer available, which is described in the Compatibility between 0.2 and 0.3 section of the 0.3 announcement. Assuming use tokio_compat_02::FutureExt;
start_server().compat().await; async fn start_server() {
HttpServer::new(move || {
App::new()
.configure(pet_routes)
}).bind("0.0.0.0:41310")?.run().await
} |
Beta Was this translation helpful? Give feedback.
-
Hi @Darksonn, Do you know if using the compatibility layer induces a performance cost, or if I should rather stay on |
Beta Was this translation helpful? Give feedback.
Tokio 0.2 and 0.3 are not directly compatible, but there is a compatibility layer available, which is described in the Compatibility between 0.2 and 0.3 section of the 0.3 announcement.
Assuming
HttpServer
requires Tokio 0.2, you can use it like this: