English 中文(简体)
Quarkus WebSocket: 无法连接到 Web 套接字
原标题:Quarkus WebSocket: cannot connect to a web socket
  • 时间:2024-08-02 08:32:26
  •  标签:
  • quarkus
I followed a guide for implementing WebSocket extension in Quarkus. https://quarkus.io/guides/websockets I adopted my code and did not manage to connect to a web socket. Then I generated a new application on https://code.quarkus.io/ with only one extension (quarkus-websockets). This is a class which define a WebSocket url. package org.acme; import jakarta.enterprise.context.ApplicationScoped; import jakarta.websocket.EncodeException; import jakarta.websocket.OnClose; import jakarta.websocket.OnError; import jakarta.websocket.OnMessage; import jakarta.websocket.OnOpen; import jakarta.websocket.Session; import jakarta.websocket.server.PathParam; import jakarta.websocket.server.ServerEndpoint; import java.io.IOException; import static java.util.Objects.requireNonNull; @ServerEndpoint("/start-websocket/{name}") @ApplicationScoped public class StartWebSocket { @OnOpen public void onOpen(Session session, @PathParam("name") String name) { System.out.println("onOpen> " + name); } @OnClose public void onClose(Session session, @PathParam("name") String name) { System.out.println("onClose> " + name); } @OnError public void onError(Session session, @PathParam("name") String name, Throwable throwable) { System.out.println("onError> " + name + ": " + throwable); } @OnMessage public void onMessage(String message, @PathParam("name") String name) { System.out.println("onMessage> " + name + ": " + message); } } I build a project and start it, the server is hosted on http://localhost:8080. I specified this url ws://localhost:8080/start-websocket/test and tried to connect via Postman, but the error Error: connect ECONNREFUSED ::1:8080 is thrown. Any ideas what could be wrong? Do I require some additional properties which are not described in the guide?
问题回答
I could not find any fix. My solution was to simply change to the WebSockets Next. https://quarkus.io/guides/websockets-next-tutorial




相关问题
Quarkus liveness doesn t work on Minikube

When I run locally (mvn compile quarkus:dev), I can access the /q/health endpoints. When I deploy the native image to docker (docker run etc etc), I can access the /q/health endpoints. When I deploy ...

Bridge JMS Message to SSE Endpoint in Quarkus

In Spring project, I used Sinks to emit events into a SSE endpoint, it worked well, check: https://github.com/hantsy/spring-graphql-sample/blob/master/dgs-subscription-sse/src/main/kotlin/com/example/...

How to resolve multi-module classpath beans in Quarkus?

In Spring it s possible to define bean dependencies in separate modules, which are then resolved via the classpath at runtime. Is it possible to do something similar in Quarkus? For example, a multi-...

Issue with AsyncHealthCheck in extension

I have an issue getting an AsyncHealthCheck working; @Readiness @ApplicationScoped public class CoreApiHealthCheck implements AsyncHealthCheck { @RestClient OqmCoreApiClientService ...

热门标签