You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i already have a axum server and am unable to use a different port for the rpc server.
I have got jsonrpsee working as a route in axum but only for http. Websocket Requests get accepted and upgraded but the Websocket is instantly closed again.
Any ideas on how to get Websockets working?
Here is my current code to wire up jsonrpsee to the axum router:
pubfnroutes(rpc_module:RpcModule<RpcState>) -> Router<super::super::AppState>{let(stop_handle, _server_handle) = stop_channel();let server_config = ServerConfig::builder().enable_ws_ping(Default::default()).build();let rpc_middleware = RpcServiceBuilder::new().layer_fn(|service| Logger{ service });let rpc_service = Server::builder().set_config(server_config).to_service_builder().set_rpc_middleware(rpc_middleware).build(rpc_module, stop_handle);let api_handler = move |State(_state):State<AppState>,session:Extension<super::auth::Session>,req:Request| {letmut service = rpc_service;asyncmove{info!("Handling api connection for user {}", session.username);match service.call(req).await{Ok(response) => response,Err(err) => {error!("RPC service error: {:?}", err);Response::builder().status(500).body("Internal Server Error".into()).unwrap()}}}};Router::new().route("/api",any(api_handler))}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
i already have a axum server and am unable to use a different port for the rpc server.
I have got jsonrpsee working as a route in axum but only for http. Websocket Requests get accepted and upgraded but the Websocket is instantly closed again.
Any ideas on how to get Websockets working?
Here is my current code to wire up jsonrpsee to the axum router:
Beta Was this translation helpful? Give feedback.
All reactions