rSocket WebSocket Postman 测试mime类型和端点

ehxuflar  于 2022-11-07  发布在  Postman
关注(0)|答案(2)|浏览(226)

我使用的是spring-boot-starter-webfluxspring-boot-starter-rsocket版本2.7.1
rSocket传输设置为websocket,如下所示:

spring.rsocket.server.transport=websocket
spring.rsocket.server.mapping-path=/rsocket

# this setting has no effect when transport==WEBSOCKET

spring.rsocket.server.port=7000

对于简单的string,有一个spring @Controller端点@MessageMapping设置,如:

@MessageMapping("test")
String test() {
        Logs.Info("***Received test***");
        return "tested";
}

我想用Postman成功完成测试。在本地运行spring Boot 应用程序并使用mime类型连接到ws://localhost:7000

dataMimeType: 'application/json'
metadataMimeType: 'message/x.rsocket.routing.v0'

就像这样:

rsocket WebSocket连接,但我无法命中端点test

带有错误1005 No Status Received: Missing status code even though one was expected

在服务器上,错误为

DEBUG [reactor-http-nio-2] debug: [c4e97d34-1, L:/127.0.0.1:7000 - R:/127.0.0.1:2051] Cancelling Websocket inbound. Closing Websocket
DEBUG [reactor-http-nio-2] debug: [c4e97d34, L:/127.0.0.1:7000 - R:/127.0.0.1:2051] Removed handler: PongHandler, pipeline: DefaultChannelPipeline{(wsencoder = io.netty.handler.codec.http.websocketx.WebSocket13FrameEncoder), (wsdecoder = io.netty.handler.codec.http.websocketx.WebSocket13FrameDecoder), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
DEBUG [reactor-http-nio-2] debug: [c4e97d34, L:/127.0.0.1:7000 ! R:/127.0.0.1:2051] An outbound error could not be processed
java.nio.channels.ClosedChannelException
at reactor.core.publisher.MonoErrorSupplied.call(MonoErrorSupplied.java:61)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:228)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203)
at reactor.core.publisher.SinkEmptyMulticast$VoidInner.complete(SinkEmptyMulticast.java:238)
at reactor.core.publisher.SinkEmptyMulticast.tryEmitEmpty(SinkEmptyMulticast.java:70)
at reactor.core.publisher.SinkEmptySerialized.tryEmitEmpty(SinkEmptySerialized.java:46)

Postman中的错误设置是什么?

7fyelxc5

7fyelxc51#

Rsocket是一个二进制协议,虽然是基于WebSocket的,但是有很多工具可以测试它。

  • 使用spring message编写单元测试
@Autowired
private RSocketRequester rSocketRequester;

StepVerifier.create(rSocketRequester
                        .route("test")
                        .retrieveMono(String.class))
                .expectNext("tested")
                .verifyComplete();
rsc --request --route=test --debug ws://localhost:7000/rsocket
nwlls2ji

nwlls2ji2#

实际上收到了以下message

{
    "data":"test",
    "metadata":4
}

每个屏幕截图

但现在服务器端的错误是:

DEBUG [reactor-http-nio-6] lambda$receive$0: receiving -> 
Frame => Stream ID: 2064452128 Type: REQUEST_N Flags: 0b100000 Length: 42 
RequestN: 539124833
Data:

DEBUG [reactor-http-nio-6] sendErrorAndClose: sending -> InvalidSetupException: SETUP or RESUME frame must be received before any others

相关问题