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

Quarkus Websockets Next connection error #43215

Closed
andreiyusupau opened this issue Sep 11, 2024 · 3 comments
Closed

Quarkus Websockets Next connection error #43215

andreiyusupau opened this issue Sep 11, 2024 · 3 comments
Labels
area/websockets env/windows Impacts Windows machines kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@andreiyusupau
Copy link

andreiyusupau commented Sep 11, 2024

Describe the bug

Hi!
I'm running into exception when trying to connect to external endpoint via Quarkus Websockets Next:

io.vertx.core.http.UpgradeRejectedException: WebSocket upgrade failure: 301
	at io.vertx.core.http.impl.WebSocketHandshakeInboundHandler.handshakeComplete(WebSocketHandshakeInboundHandler.java:102)
	at io.vertx.core.http.impl.WebSocketHandshakeInboundHandler.channelRead(WebSocketHandshakeInboundHandler.java:84)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Jakarta WS works well for this case, examples below.

Expected behavior

Connection to wss://example.com/ws is established successfully.

Actual behavior

No response

How to Reproduce?

Here is my WS Next client:

@WebSocketClient(path = "/ws")
public class WebsocketClientNext {

    @OnOpen
    void onOpen(WebSocketClientConnection connection) {
        System.out.println("Opened");
    }

    @OnTextMessage
    void onMessage(String message, WebSocketClientConnection connection) {
        System.out.println(message);
    }

}

And it's wrapper:

@ApplicationScoped
public class WebsocketClientNextWrapper {

    @Inject
    WebSocketConnector<WebsocketClientNext> connector;

    public void openAndSendMessage() {
        var connection = connector.baseUri(URI.create("wss://example.com"))
                .connectAndAwait();
    }

Same problem with basic implementation:

@ApplicationScoped
public class WebsocketClientNextBasicWrapper {

    @Inject
     BasicWebSocketConnector connector;

    public void openAndSendMessage() {
        connector.baseUri(URI.create("wss://example.com"))
                .path("/ws")
                .executionModel(BasicWebSocketConnector.ExecutionModel.VIRTUAL_THREAD)
                .onOpen((c) -> {
                    System.out.println("Opened");
                })
                .onTextMessage((c, m) -> {
                    System.out.println(m);
                })
                .connectAndAwait();
     }
}

Example with Jakarta WS that works fine:

@ClientEndpoint
public class WebsocketClient {

    public WebsocketClient() {
        try {
            var container = ContainerProvider.getWebSocketContainer();
            container.connectToServer(this, URI.create("wss://example.com/ws"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @OnOpen
    public void open(Session session) {
        System.out.println("Opened");
    }

    @OnMessage
    void message(String msg) {
        System.out.println(msg);
    }

}

Output of uname -a or ver

Microsoft Windows [Version 10.0.22631.4037]

Output of java -version

Amazon Corretto 21.0.1

Quarkus version or git rev

3.14.1

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 8.10

Additional information

No response

@andreiyusupau andreiyusupau added the kind/bug Something isn't working label Sep 11, 2024
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Sep 11, 2024
@geoand
Copy link
Contributor

geoand commented Sep 11, 2024

cc @mkouba

@mkouba
Copy link
Contributor

mkouba commented Sep 11, 2024

I believe that this was fixed in 3.14.2; here's the PR: #42826

@andreiyusupau could you pls try your app with Quarkus 3.14.2?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Sep 11, 2024
@andreiyusupau
Copy link
Author

@mkouba Works fine, thanks for quick response.

@geoand geoand added triage/out-of-date This issue/PR is no longer valid or relevant and removed triage/needs-feedback We are waiting for feedback. labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/websockets env/windows Impacts Windows machines kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests

3 participants