-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject connections before accepting them #72
Comments
In Axum there's a way - take a look at this example: ezsockets/examples/chat-server-axum/src/main.rs Lines 150 to 158 in 52c4b78
You can do some work before calling |
It's good to know this can be solved in Axum. The tungstenite integration does not have a solution right now, so I am reopening to track that issue. |
Yes that's true. |
Currently you can only reject a connection after the websockets backend has accepted the connection. This means clients will always see 'connected' -> 'disconnected' events even if their connection request was rejected by your custom
ServerExt
.There should be an additional step in the connection-acceptance protocol for pre-validating requests before the websockets backend can accept the connection.
It should be possible to move that step into the axum
Upgrade::from_request()
method and tungsteniteAcceptor .. callback
closure, although it's not clear the optimal/correct approach since server actors are async from their servers (there is a risk of introducing race conditions between pre-validating requests and registering connections in theServerExt
, e.g. if you reject duplicate connections).The text was updated successfully, but these errors were encountered: