-
|
Dear all, I'm trying to use zenoh in the backend of a fullstack application using dioxus-0.7. I've been trying to use something like this: #[cfg(feature = "server")]
#[tokio::main]
async fn main() {
// Start the server
let address = dioxus::cli_config::fullstack_address_or_localhost();
let router = axum::Router::new()
// You can add a dioxus application to the router with the `serve_dioxus_application` method
// This will add a fallback route to the router that will serve your component and server functions
.serve_dioxus_application(dioxus_server::ServeConfig::new(), App);
let router = router.into_make_service();
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
tokio::spawn(async move {
axum::serve(listener, router).await.unwrap();
});
dioxus::LaunchBuilder::server()
.with_cfg(ServeConfig::default())
.launch(App);
}to start the server, but then tokio complains: Then I tried the following: fn main() {
#[cfg(feature = "web")]
dioxus::launch(App);
#[cfg(feature = "server")]
{
let middleware_runtime = tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.thread_name("middleware-pool")
.enable_all()
.build()
.expect("Failed to create middleware runtime");
let dioxus_rt = tokio::runtime::Builder::new_current_thread()
.thread_name("dioxus-pool")
.enable_all()
.build()
.expect("Failed to create dioxus runtime");
middleware_runtime.spawn(async move { api::server::init_server_background_task().await });
dioxus_rt.block_on(async move {
launch_server().await;
});
}
}
#[cfg(feature = "server")]
async fn launch_server() {
use axum::routing::get;
use axum::{
body::Body,
http::header,
response::{IntoResponse, Response},
Router,
};
use dioxus::prelude::*;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let address = dioxus::cli_config::fullstack_address_or_localhost();
let router = Router::new()
.serve_dioxus_application(ServeConfig::default(), App);
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
axum::serve(listener, router).await.unwrap();
}The result is the same: Is there any supported way to break the cycle? |
Beta Was this translation helpful? Give feedback.
Answered by
w1n5t0n99
Feb 21, 2026
Replies: 1 comment 1 reply
-
|
This worked for me |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
oleid
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked for me