从RSocket-Java客户端连接到Spring Boot RSocket服务器时出错

用户名

通过TCP连接到Spring Boot RSocket应用程序时出现问题。使用RSocketRequester时,客户端工作正常,但是当我尝试使用RSocketFactory客户端进行连接时,它会不断出错。下面的代码。

        RSocket rSocket = this.client = RSocketFactory
            .connect()
            .mimeType(WellKnownMimeType.MESSAGE_RSOCKET_ROUTING.toString(), MediaType.APPLICATION_JSON_VALUE)
            .frameDecoder(PayloadDecoder.ZERO_COPY)
            .transport(TcpClientTransport.create("localhost", 7000))
            .start()
            .block();


Flux<Payload> s = rSocket.requestStream(DefaultPayload.create("1234", "socket"));
    s.subscribe();

这给出了如下错误:

java.lang.IndexOutOfBoundsException: readerIndex(1) + length(115) exceeds writerIndex(6): AbstractPooledDerivedByteBuf$PooledNonRetainedSlicedByteBuf(ridx: 1, widx: 6, cap: 6/6, unwrapped: PooledUnsafeDirectByteBuf(ridx: 27, widx: 27, cap: 1024))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1477)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1463)
at io.netty.buffer.AbstractByteBuf.readSlice(AbstractByteBuf.java:880)
at io.rsocket.metadata.TaggingMetadata$1.next(TaggingMetadata.java:47)
at io.rsocket.metadata.TaggingMetadata$1.next(TaggingMetadata.java:37)
at org.springframework.messaging.rsocket.DefaultMetadataExtractor.extractEntry(DefaultMetadataExtractor.java:136)
at org.springframework.messaging.rsocket.DefaultMetadataExtractor.extract(DefaultMetadataExtractor.java:119)
at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.createHeaders(MessagingRSocket.java:195)
at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:167)
at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.requestStream(MessagingRSocket.java:127)
at io.rsocket.RSocketResponder.requestStream(RSocketResponder.java:207)
at io.rsocket.RSocketResponder.handleFrame(RSocketResponder.java:310)
at reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:160)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:242)
at reactor.core.publisher.FluxGroupBy$UnicastGroupedFlux.drainRegular(FluxGroupBy.java:554)
at reactor.core.publisher.FluxGroupBy$UnicastGroupedFlux.drain(FluxGroupBy.java:630)
at reactor.core.publisher.FluxGroupBy$UnicastGroupedFlux.subscribe(FluxGroupBy.java:696)
at reactor.core.publisher.Flux.subscribe(Flux.java:8174)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onNext(MonoFlatMapMany.java:188)
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
at reactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:317)
at io.rsocket.internal.ClientServerInputMultiplexer.lambda$new$1(ClientServerInputMultiplexer.java:116)
at reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:160)
at reactor.core.publisher.FluxGroupBy$GroupByMain.drainLoop(FluxGroupBy.java:380)
at reactor.core.publisher.FluxGroupBy$GroupByMain.drain(FluxGroupBy.java:316)
at reactor.core.publisher.FluxGroupBy$GroupByMain.onNext(FluxGroupBy.java:201)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:114)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:114)
at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:218)
at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:351)
at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:348)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:90)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:830)

据我了解,此特定错误是由于netty消息包装(来自stackoverflow上的其他线程)引起的,但是如何解决呢?服务器是Spring Boot 5+ RSocket,但是客户端仅使用RSocket-Java。

用户名

这个,使用以下方法来产生元数据。

CompositeByteBuf metadata = ByteBufAllocator.DEFAULT.compositeBuffer();
RoutingMetadata routingMetadata = TaggingMetadataCodec.createRoutingMetadata(ByteBufAllocator.DEFAULT, List.of("/route"));
CompositeMetadataCodec.encodeAndAddMetadata(metadata,
        ByteBufAllocator.DEFAULT,
        WellKnownMimeType.MESSAGE_RSOCKET_ROUTING,
        routingMetadata.getContent());

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

RSocket Js客户端未获取从Spring Boot RSocket服务器生成的元素

来自分类Dev

C#Net RSocket客户端与Java RSocket服务器的无效的MIME类型“二进制”

来自分类Dev

Spring StandardWebsocketClient是否可以连接到Spring Boot RSocket Server?

来自分类Dev

如何使用rsocket在Spring Boot中配置SSL / TLS?

来自分类Dev

方法RSocket服务器异常:没有处理程序目的地“”(目标不通过从客户端到服务器)

来自分类Dev

Spring Rsocket Server使用RSocket-Java进行rsocket路由元数据

来自分类Dev

Spring Boot SSL客户端-服务器通信

来自分类Dev

如何使用Spring Security在Spring Boot应用程序中配置RSocket安全

来自分类Dev

如何在Spring Boot RSocket反应式中处理入站流取消

来自分类Dev

在Spring Boot中编写客户端以连接到Websocket

来自分类Dev

从客户端连接Ubuntu服务器时出错

来自分类Dev

通过特定客户端连接到centos服务器时出错

来自分类Dev

将Android客户端连接到NodeJS中的套接字服务器时出错

来自分类Dev

通过特定客户端连接到centos服务器时出错

来自分类Dev

连接到Java服务器时Android客户端崩溃

来自分类Dev

spring-boot-admin 服务器和客户端的区别

来自分类Dev

hazelcast客户端无法连接到服务器

来自分类Dev

Qt客户端-连接到C服务器

来自分类Dev

从客户端连接到基于Sails的服务器

来自分类Dev

SignalR 从服务器连接到客户端

来自分类Dev

Spring集成多个客户端连接到服务器端口

来自分类Dev

Spring Cloud Config:客户端不会尝试连接到配置服务器

来自分类Dev

Spring集成连接到服务器端口的多个客户端

来自分类Dev

ubuntu服务器上启动spring boot jar的问题。启动ApplicationContext时出错

来自分类Dev

在 tomcat 外部服务器上部署 spring boot restfull api 时出错

来自分类Dev

表示http客户端连接到服务器,https客户端无法连接到服务器

来自分类Dev

连接到在boot2docker(centos容器| Windows 7.1主机)中运行的python服务器时出错

来自分类Dev

Jetty Java Websocket客户端未连接到服务器

来自分类Dev

将MySQL连接到Java客户端/服务器应用程序

Related 相关文章

  1. 1

    RSocket Js客户端未获取从Spring Boot RSocket服务器生成的元素

  2. 2

    C#Net RSocket客户端与Java RSocket服务器的无效的MIME类型“二进制”

  3. 3

    Spring StandardWebsocketClient是否可以连接到Spring Boot RSocket Server?

  4. 4

    如何使用rsocket在Spring Boot中配置SSL / TLS?

  5. 5

    方法RSocket服务器异常:没有处理程序目的地“”(目标不通过从客户端到服务器)

  6. 6

    Spring Rsocket Server使用RSocket-Java进行rsocket路由元数据

  7. 7

    Spring Boot SSL客户端-服务器通信

  8. 8

    如何使用Spring Security在Spring Boot应用程序中配置RSocket安全

  9. 9

    如何在Spring Boot RSocket反应式中处理入站流取消

  10. 10

    在Spring Boot中编写客户端以连接到Websocket

  11. 11

    从客户端连接Ubuntu服务器时出错

  12. 12

    通过特定客户端连接到centos服务器时出错

  13. 13

    将Android客户端连接到NodeJS中的套接字服务器时出错

  14. 14

    通过特定客户端连接到centos服务器时出错

  15. 15

    连接到Java服务器时Android客户端崩溃

  16. 16

    spring-boot-admin 服务器和客户端的区别

  17. 17

    hazelcast客户端无法连接到服务器

  18. 18

    Qt客户端-连接到C服务器

  19. 19

    从客户端连接到基于Sails的服务器

  20. 20

    SignalR 从服务器连接到客户端

  21. 21

    Spring集成多个客户端连接到服务器端口

  22. 22

    Spring Cloud Config:客户端不会尝试连接到配置服务器

  23. 23

    Spring集成连接到服务器端口的多个客户端

  24. 24

    ubuntu服务器上启动spring boot jar的问题。启动ApplicationContext时出错

  25. 25

    在 tomcat 外部服务器上部署 spring boot restfull api 时出错

  26. 26

    表示http客户端连接到服务器,https客户端无法连接到服务器

  27. 27

    连接到在boot2docker(centos容器| Windows 7.1主机)中运行的python服务器时出错

  28. 28

    Jetty Java Websocket客户端未连接到服务器

  29. 29

    将MySQL连接到Java客户端/服务器应用程序

热门标签

归档