rSocket websocket postman testing mime types and endpoints

1.2k Views Asked by At

I am using spring-boot-starter-webflux and spring-boot-starter-rsocket version 2.7.1

The rSocket transport is set to websocket like this:

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

# this setting has no effect when transport==WEBSOCKET
spring.rsocket.server.port=7000

There's a spring @Controller endpoint @MessageMapping setup for a simple string like:

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

I want to get a successful test done with Postman. Run the spring boot app locally and connect to ws://localhost:7000 using mime types

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

Like this:

mime types

The rsocket websocket connects, but I can't hit the endpoint test

test

With error 1005 No Status Received: Missing status code even though one was expected

error

On the server the error is

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)

What's the incorrect setting in Postman?

2

There are 2 best solutions below

1
echooymxq On

The answer is don't use postman. Rsocket is a binary protocol, Even though based on Websocket, There are many tools test it.

  • use spring message write a unit test
@Autowired
private RSocketRequester rSocketRequester;

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

Actually the following message was received:

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

Per screenshot

test

But now the error on the server side is:

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