Comments (3)
Because the protocol specification doesn't specify that the initial connect response should be alone. And with http polling it is possible to have multiple packets in one response:
So for performance reasons if two packets are emitted at almost the same time they will be buffered.
socketioxide/engineioxide/src/transport/ws.rs
Lines 239 to 247 in a11edd6
If you have any other questions, please open a discussion in the discussions panel or on the #socketioxide channel on the tokio discord server
from socketioxide.
Could you please add a demo code of the client and server? Without this I won't be able to see what's wrong.
I suspect that it is the client that is not configured correctly to upgrade to websocket. As it is the responsability of the client to initialize a websocket upgrade request.
from socketioxide.
I managed to fix it, in fact, transports was missing: ["polling", "websocket"]. I had only defined polling.
Taking advantage, I would like to know why the emit that I am triggering when the user connects is going along with the Socketioxide connection process?
Here below is an example:
Now notice the second image, which indicates where the emitted data is being received:
Part of the code that accomplishes this:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing::subscriber::set_global_default(FmtSubscriber::default())?;
let messages = state::MessageStore::default();
let sockets = state::SocketDataStore::default();
let (layer, io) = SocketIo::builder().with_state(messages).with_state(sockets).build_layer();
io.ns("/", |socket: SocketRef, Data(auth): Data<types::AuthData>, store: State<state::SocketDataStore>| async move {
fn emit_wrapper(event: String, socket: &SocketRef, id: String, data: impl serde::Serialize) {
let _result = socket
.within(id)
.emit(event, data).ok();
}
emit_wrapper("person:connected".to_string(), &socket, socket_data.clone().id.clone().to_string(),
types::PersonConnected {
user_id: socket_data.clone().user_id,
extension: socket_data.clone().extension.clone().unwrap_or("".to_string()),
}
);
});
let app = axum::Router::new()
.route("/", get(|| async { "Hello, World!" }))
.route("/hello", get(handler))
.with_state(io)
.layer(
ServiceBuilder::new()
.layer(CorsLayer::permissive())
.layer(layer),
);
info!("Starting server");
axum::Server::bind(&"0.0.0.0:3010".parse().unwrap())
.serve(app.into_make_service())
.await?;
Ok(())
}
from socketioxide.
Related Issues (20)
- Inconsistent binary packet ordering HOT 3
- Automatic crate publishing
- Custom parser support HOT 2
- Feature reqwest: List all rooms HOT 1
- Using TLS to encrypt all messages HOT 2
- WebTransport support HOT 1
- Add middlewares services to namespaces
- All events get blocked when socket is emitting lots of data HOT 14
- Several handlers for a single event HOT 2
- Binary packet placeholder handling does not handle all possible messages
- Relationship between `Bin` and the structure of `Data` can be ambiguous for binary packets HOT 14
- Binary events sent to handlers have a 0x4 byte prepended to the binary data (v4 server) HOT 2
- `OPTIONS` request should not return `BadHandshakeMethod` error HOT 1
- Add default event "connection" HOT 1
- Cannot keep ref to extension objects across .await points in handlers/middlewares HOT 3
- delete_ns blocks thread indefinitely HOT 1
- MongoDB Adpter HOT 1
- Hold a per `Client` state rather than a static state. HOT 1
- Unnecessary panic on Message enum match arms HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socketioxide.