@Controller
public class ServerController {

    @MessageMapping(value = "market")
    public MarketResponse getMarket(Market market) {
        return new MarketResponse(market.getName());
    }
}
@RestController
public class ConsumerController {

    private final RSocketRequester rSocketRequester;

    public ConsumerController(RSocketRequester rSocketRequester) {
        this.rSocketRequester = rSocketRequester;
    }

    @GetMapping(path = "/market/{name}")
    public Publisher<MarketResponse> getMarket(@PathVariable String name) {
        return rSocketRequester.route("market").data(new Market(name)).retrieveMono(MarketResponse.class);
    }
}
java.lang.IllegalArgumentException: No decoder for com.example.rsocketclient.MarketResponse
    at org.springframework.messaging.rsocket.RSocketStrategies.decoder(RSocketStrategies.java:92) ~[spring-messaging-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ HTTP GET "/market/test" [ExceptionHandlingWebHandler]

Comment From: huangshayang

@Data
public class MarketResponse {
    private String res;

    public MarketResponse(String res) {
        this.marketResponse("Hello" + res + Instant.now());
    }

    private MarketResponse marketResponse(String res) {
        this.res = res;
        return this;
    }
}

Comment From: rstoyanchev

It says "No decoder". Why do you consider it a bug? It is most likely a configuration issue.

Comment From: rstoyanchev

I am closing this for now. Feel free to comment further, if you suspect that it is indeed a bug. For that you'll need to check what encoder/decoder should be used, is it actually configured, etc.

Comment From: huangshayang

@Configuration
public class ConsumerConfig {

    @Bean
    RSocket rSocket() {
        return RSocketFactory
                .connect()
                .dataMimeType(MimeTypeUtils.APPLICATION_JSON_VALUE)
                .frameDecoder(PayloadDecoder.ZERO_COPY)
                .transport(TcpClientTransport.create(7000))
                .start()
                .block();
    }

    @Bean
    RSocketRequester rSocketRequester() {
        return RSocketRequester.wrap(this.rSocket(), MimeTypeUtils.APPLICATION_JSON, MimeTypeUtils.APPLICATION_JSON, RSocketStrategies.builder().build());
    }
}

@rstoyanchev what do you mean ?this is my configuration is`s not error

Comment From: rstoyanchev

Provide a sample please.

Comment From: heesuk-ahn

do you solved this? I have seen this error before.

so I shared my example code.

@Configuration
public class ClientConfiguration {

    @Bean
    public RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) {
        return RSocketRequester.builder()
                .rsocketStrategies(rSocketStrategies)
                .dataMimeType(MimeTypeUtils.APPLICATION_JSON)
                .connectTcp("localhost", 7000)
                .block();
    }

}

By Using RSocketStrategies, we can set Encoder and Decoder. as far as I know, RSocketStrategies autoconfiguration defaults to setting Jackson.

do you check for this document?

  • https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java

Comment From: huangshayang

do you solved this? I have seen this error before.

so I shared my example code.

``` @Configuration public class ClientConfiguration {

@Bean
public RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) {
    return RSocketRequester.builder()
            .rsocketStrategies(rSocketStrategies)
            .dataMimeType(MimeTypeUtils.APPLICATION_JSON)
            .connectTcp("localhost", 7000)
            .block();
}

} ```

By Using RSocketStrategies, we can set Encoder and Decoder. as far as I know, RSocketStrategies autoconfiguration defaults to setting Jackson.

do you check for this document?

  • https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java
@Configuration
public class ClientConfiguration {
    @Bean
    public RSocket rSocket() {
        return RSocketFactory
                .connect()
                .dataMimeType(MimeTypeUtils.ALL_VALUE)
                .frameDecoder(PayloadDecoder.ZERO_COPY)
                .transport(TcpClientTransport.create(7000))
                .start()
                .block();
    }

    @Bean
    RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) {
        return RSocketRequester.builder()
                .rsocketFactory(factory -> factory
                .dataMimeType(MimeTypeUtils.ALL_VALUE)
                .frameDecoder(PayloadDecoder.ZERO_COPY))
                .rsocketStrategies(rSocketStrategies)
                .connect(TcpClientTransport.create(7000))
                .retry().block();
    }
}

try it, @heesuk-ahn

Comment From: ghostidentity

if you are doing modular project, then adding this line in module.info.java: requires com.fasterxml.jackson.core; should clear up the issue. By default, auto configuration should do all of this, but with modular design there are restriction.

Comment From: pygmalion0909

@heesuk-ahn Thank you! I solved it!