Unable to make socketioxide serve requests from custom req_path #571
-
Hi, I’m trying to configure my server to handle WebSocket requests on a custom This is what I have tried, let engine_config = EngineIoConfig {
req_path: settings.server.path.into(),
..Default::default()
};
let mut socketio_config = SocketIoConfig::default();
socketio_config.engine_config = engine_config;
let (layer, io) = SocketIo::builder()
.with_config(socketio_config)
.with_state(Arc::clone(&app_state))
.with_adapter::<RedisAdapter<_>>(adapter)
.build_layer();
let _ = app_state.socket_io.set(io.clone());
io.ns("/", on_connect).await?;
let app = axum::Router::new()
.route("/", get(|| async { "ok" }))
.layer(layer) Prior to this, I had ngnix rewriting paths in the request this way
This setup worked perfectly. After removing the nginx path rewrite, I expected socketioxide to handle requests directly on /xxx/socket.io/ (the custom path set in req_path). However, it seems like the server still only accepts connections on /socket.io/ and ignores /xxx/socket.io/. Trace on config Traces prior to removing path rewrite After removing nginx path rewrite Is there an extra step I’m missing to get socketioxide to recognize the custom path directly? How can I configure axum and socketioxide to serve WebSocket requests on a custom namespace/path without relying on nginx rewrites? Any pointers or examples would be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry, I am not sure as to what i did to make it work, I changed the builder into this let (layer, io) = SocketIo::builder()
.req_path(settings.server.path.clone())
.with_state(Arc::clone(&app_state))
.with_adapter::<RedisAdapter<_>>(adapter)
.build_layer(); And it seems to pick up from the new path. I must have made a mistake somewhere else. |
Beta Was this translation helpful? Give feedback.
Sorry, I am not sure as to what i did to make it work,
I changed the builder into this
And it seems to pick up from the new path. I must have made a mistake somewhere else.