Skip to content

Quarkus WebSockets Next Intercepting HTTP GET Requests when using the @WebSocket annotation #47574

@Aravinda93

Description

@Aravinda93

Quarkus WebSockets Next Intercepting HTTP GET Requests when using the @websocket annotation

After moving from quarkus-websocket to quarkus-websockets-next, any HTTP GET to a @WebSocket path now errors with

"Connection" header must be "Upgrade"

This is because the new extension intercepts every matching request and treats it as a WebSocket handshake.

In the old quarkus-websocket model, @ServerEndpoint only handled true WebSocket upgrades; plain GETs to the same URL would fall through to JAX-RS resources.

With quarkus-websockets-next, @WebSocket(path="/…") installs a single Vert.x handler for all HTTP methods on that path. A standard GET—lacking the required Connection: Upgrade header—gets caught and rejected before any REST logic can run.

Below is a minimal Quarkus project showing:

  1. Legacy (quarkus-websockets):

    • A REST @GET /chat endpoint
    • A JSR-356 WebSocket @ServerEndpoint("/chat")
      GET works (200 OK), WS works
  2. Next (quarkus-websockets-next):

    • Same REST resource
    • New @WebSocket(path = "/chat")
      Any GET /chat now fails with
"Connection" header must be "Upgrade"

Sample reproduction using:

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-websockets</artifactId>
</dependency>

ChatResource.java:

@Path("/chat")
@ApplicationScoped
public class ChatResource {
    @GET
    public String hello() {
        return "Hello from REST!";
    }
}

ChatEndpoint.java:

@ServerEndpoint("/chat")
@ApplicationScoped
public class ChatEndpoint {
    @OnOpen
    public void onOpen(Session session) { /*...*/ }

    @OnMessage
    public void onMessage(Session session, String msg) {
        session.getAsyncRemote().sendText("Echo:" + msg);
    }
}

Behavior

GET http://localhost:8080/chat → 200 OK with “Hello from REST!”

ws://localhost:8080/chat → WebSocket handshake succeeds

With the new quarkus-websockets-next:

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-websockets-next</artifactId>
</dependency>

ChatResource.java (unchanged):

@Path("/chat")
@ApplicationScoped
public class ChatResource {
    @GET
    public String hello() {
        return "Hello from REST!";
    }
}

ChatSocket.java:

@WebSocket(path = "/chat")
@ApplicationScoped
public class ChatSocket {
    @OnOpen
    public void onOpen(WebSocketConnection conn) { /*...*/ }

    @OnMessage
    public void onMessage(WebSocketConnection conn, String msg) {
        conn.sendText("Echo:" + msg).subscribe().with(r -> {}, t -> {});
    }
}

Behavior

GET http://localhost:8080/chat
→ fails with

"Connection" header must be "Upgrade"

ws://localhost:8080/chat → WebSocket handshake succeeds

Is this expected from the quarkus-websockets-next or is this a bug? Because I am implementing some endpoints for a standard specification where I can have the endpoints something like this:

/queries/{queryName}/events

As per the specification, it should do the following:

Returns all events that match the query or creates a new Websocket subscription.

This was working with the quarkus-websockets and now failing the GET request with quarkus-websockets-next so bit confusing if this is an issue that needs a fix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions