Coder Social home page Coder Social logo

Cannot open WebSocket with Sec-WebSocket-Protocol header in Quarkus version 3.7.1 and above with quarkus-websockets package about quarkus HOT 11 CLOSED

paolo-cutilli-eudata avatar paolo-cutilli-eudata commented on September 28, 2024
Cannot open WebSocket with Sec-WebSocket-Protocol header in Quarkus version 3.7.1 and above with quarkus-websockets package

from quarkus.

Comments (11)

sberyozkin avatar sberyozkin commented on September 28, 2024

I'm not seeing anything in https://github.com/quarkusio/quarkus/commits/main/extensions/websockets that might've caused it. @mkouba @cescoffier, please comment if you have some ideas

from quarkus.

mkouba avatar mkouba commented on September 28, 2024

@paolo-cutilli-eudata Hm, I've tried to connect to the endpoint using new WebSocket("ws://" + location.host + "/ws", "custom-protocol") in JS and it seems to work - I can even see the log message Socket opened: abcdef... in the console. In fact, the protocols paremeter seems to be ignored completely. I don't know if that's expected though, in the sense that the server can fall back to the default protocol if no matching protocol is found.

By the way, I don't think that @RequestScoped is a good match for a jakarta.websocket server endpoint. The spec does not say anything about CDI contexts so I'd say that @ApplicationScoped/@Dependent would be a "safer" choice.

from quarkus.

paolo-cutilli-eudata avatar paolo-cutilli-eudata commented on September 28, 2024

@mkouba thank you for the suggestion about the @RequestScoped annotation.

regarding the WebSocket, i tried your approach in JS directly from the /q/dev page and i cannot open the WebSocket.
i can see the open log message too, but immediatly followed by the close message

Socket opened: pBnZ5eTS0EYXXBFK-KunRgXVdcMgFoMt_-rdsF-7
Socket closed: pBnZ5eTS0EYXXBFK-KunRgXVdcMgFoMt_-rdsF-7 - 

and the following error

image

is there additional information that i can give you so that you can reproduce the problem?

from quarkus.

mkouba avatar mkouba commented on September 28, 2024

Hm, I do not observe this behavior 🤷.

is there additional information that i can give you so that you can reproduce the problem?

I can't think of anything.

from quarkus.

paolo-cutilli-eudata avatar paolo-cutilli-eudata commented on September 28, 2024

@mkouba I gathered some other interesting information. The same test described above works in Firefox.
From Chrome it does not work. I tried Postman WebSocket also and it does not work from there. I have Postman installed as a snap package on Ubuntu that i think it's based on electron/chromum engine. Do you think that this can be useful to circumscribe the problem?

from quarkus.

mkouba avatar mkouba commented on September 28, 2024

@mkouba I gathered some other interesting information. The same test described above works in Firefox. From Chrome it does not work. I tried Postman WebSocket also and it does not work from there. I have Postman installed as a snap package on Ubuntu that i think it's based on electron/chromum engine. Do you think that this can be useful to circumscribe the problem?

It might be related. On the other hand, I've tried with Chromium (Version 122.0.6261.94 (Official Build) snap (64-bit)) and it worked just fine.

from quarkus.

paolo-cutilli-eudata avatar paolo-cutilli-eudata commented on September 28, 2024

@mkouba I gathered some other interesting information. The same test described above works in Firefox. From Chrome it does not work. I tried Postman WebSocket also and it does not work from there. I have Postman installed as a snap package on Ubuntu that i think it's based on electron/chromum engine. Do you think that this can be useful to circumscribe the problem?

It might be related. On the other hand, I've tried with Chromium (Version 122.0.6261.94 (Official Build) snap (64-bit)) and it worked just fine.

Same configuration - Chromium Version 122.0.6261.94 (Official Build) snap (64-bit) - throws this error

image

from quarkus.

mkouba avatar mkouba commented on September 28, 2024

@sberyozkin Could you pls run this ^ test too?

from quarkus.

istosSchulz avatar istosSchulz commented on September 28, 2024

We have the exact same issue after upgrading to Quarkus 3.8.1. We downgraded to 3.6.9 to get it working. The upgrade to 3.7.0/3.7.1 seems to be the one that breaks it.
Same errors and behaviour. Our custom protocol is called differently but the issue seems to be the same. @OnOpen is called seemingly successful and immediately afterwards @OnClose is called. The client (Postman) reports "Error: Server sent no subprotocol".
We've integrated a ServerEndpointConfig.Configurator to inspect the request and response objects while handshake is happening but they seem to be ok. They contain the exact same headers in the working and in the broken version of Quarkus. When @OnClose is called the reported CloseReason is Going Away (1001).

from quarkus.

cescoffier avatar cescoffier commented on September 28, 2024

It is likely due to:

from quarkus.

cescoffier avatar cescoffier commented on September 28, 2024

Confirmed - See quarkusio/quarkus-http#143.

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.