Код: Выделить всё
org.springframework.boot
spring-boot-starter-graphql
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-webflux
Код: Выделить всё
WebSocketClient webSocketClient = new ReactorNettyWebSocketClient();
WebSocketGraphQlClient graphQlWebSocketClient = WebSocketGraphQlClient
.builder("ws://" + this.ip + ":" + this.port + "/subscriptions", webSocketClient)
.header("Authorization", "Session " + session.uuid())
.build();
String subscription = """
subscription {
userStatusChanged {
id
createdAt
updatedAt
username
firstName
lastName
mail
role
}
}
""";
graphQlWebSocketClient.document(subscription)
.retrieveSubscription("userStatusChanged")
.toEntity(UserResponse.class)
.subscribe(userResponse -> log.info(userResponse.toString()),
error -> log.info("Error : " + error),
() -> log.info("Subscription completed")
);
Код: Выделить всё
io.netty.handler.codec.http.websocketx.WebSocketClientHandshakeException: Invalid subprotocol. Actual: . Expected one of: graphql-transport-ws
at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.finishHandshake(WebSocketClientHandshaker.java:389) ~[netty-codec-http-4.1.101.Final.jar:4.1.101.Final]
at reactor.netty.http.client.WebsocketClientOperations.onInboundNext(WebsocketClientOperations.java:121) ~[reactor-netty-http-1.0.39.jar:1.0.39]
Код: Выделить всё
WebSocketClient webSocketClient = new StandardWebSocketClient();
WebSocketGraphQlClient graphQlWebSocketClient = WebSocketGraphQlClient
.builder("ws://" + this.ip + ":" + this.port + "/subscriptions", webSocketClient)
.header("Authorization", "Session " + session.uuid())
.header("Sec-WebSocket-Protocol", "graphql-ws")
.build();
Код: Выделить всё
WebSocketGraphQlTransport : Closing StandardWebSocketSession[id=0, uri=ws://172.16.60.198:8081/subscriptions]: org.springframework.core.codec.DecodingException: JSON decoding error: No matching constant for [ka]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: No matching constant for [ka]
at [Source: (org.springframework.core.io.buffer.DefaultDataBuffer$DefaultDataBufferInputStream); line: 1, column: 9] (through reference chain: org.springframework.graphql.server.support.GraphQlWebSocketMessage["type"])
Что мне делать, чтобы устранить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/787 ... s-protocol
Мобильная версия