Код: Выделить всё
"Connection" header must be "Upgrade"
Код: Выделить всё
quarkus-websockets- Rest @get/Chat endpoint
- a jsr-356 websocket @serverendpoint ("/CHAT")
Пример воспроизведения с использованием: < /p>
io.quarkus
quarkus-websockets
< /code>
ChatResource.java[/code]::Код: Выделить всё
@Path("/chat") @ApplicationScoped public class ChatResource { @GET public String hello() { return "Hello from REST!"; } } < /code> 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); } } < /code> 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:Код: Выделить всё
io.quarkus quarkus-websockets-next < /code> ChatResource.java (unchanged):Код: Выделить всё
@Path("/chat") @ApplicationScoped public class ChatResource { @GET public String hello() { return "Hello from REST!"; } } < /code> ChatSocket.javaили это ошибка? Потому что я внедряю некоторые конечные точки для стандартной спецификации, где я могу иметь конечные точки что -то вроде этого: < /p>Код: Выделить всё
@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 -> {}); } } < /code> Behavior GET http://localhost:8080/chat → fails with "Connection" header must be "Upgrade" < /code> ws://localhost:8080/chat → WebSocket handshake succeeds Is this expected from the quarkus-websockets-nextи теперь сбой запроса GET с Quarkus-websockets-next , так что сбивает с толку, если это проблема, которая требует исправления.Код: Выделить всё
/queries/{queryName}/events < /code> As per the specification, it should do the following: Returns all events that match the query or creates a new Websocket subscription. < /code> This was working with the quarkus-websockets
Подробнее здесь: https://stackoverflow.com/questions/795 ... -websocket