Skip to content
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

connect does not notify the user when a websocket connection isn't upgraded #82

Open
EthanLozano opened this issue Nov 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@EthanLozano
Copy link
Contributor

Describe the bug

(Apologies in advance: I'm not sure which layer is potentially failing, or if I'm failing to interact with a layer properly. There is a good chance that this isn't a bug with websocket-kit)

WebSocket.connect does not appear to notify the user if the server decides not to upgrade the request. Specifically, .whenFailure is never triggered on the resulting EventLoopFuture.

To Reproduce

I'm using a vapor server, and my webSocket route defines a shouldUpgrade function that returns nil (under certain conditions):

shouldUpgrade: { req in
    ...
    req.eventLoop.makeSucceededFuture(nil)
}

I believe that returning nil is the correct use of the vapor API, but I also tried returning a failed future without any success:

req.eventLoop.makeFailedFuture(Abort(.forbidden))

On the client side, no code is triggered to alert the client that the upgrade failed

let result = WebSocket.connect(...)
result.whenFailure { error in
    // not triggered
}

Expected behavior

I would expect .whenFailure to be executed. Or, I would expect the API to support a closure for when the upgrade was rejected.

Environment

  • Vapor websocket-kit: 2.1.2
  • Vapor Framework version: 4.35.0
  • Vapor Toolbox version: 18.0.0
  • OS version: Mac OS 11.0.1 (20B50)
@EthanLozano EthanLozano added the bug Something isn't working label Nov 28, 2020
@fumoboy007
Copy link
Contributor

fumoboy007 commented Jan 17, 2023

The root cause for this issue is vapor/vapor#2932.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants