rsocket error 0x201(应用程序错误):readerindex(1)+长度(102)超过writerindex(8):unoledSlicedByteBu

bvn4nwqk  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(336)
setInterval(() => {
        let that = this;
        this.socket && this.socket.requestResponse({
            data: '' + (++index),
            metadata: 'org.mvnsearch.account.AccountService.findById',
        }).subscribe({
            onComplete(payload) {
                let account = JSON.parse(payload.data);
                that.setState({
                    nick: account.nick
                })
            },
            onError: (e) => {
                console.log('onError', e)
            }
        });
    }, 2000)



正在尝试使用reactjs连接到spring rsocket。在下面显示的javascript代码中,在订阅之前获取一个错误。


**this.socket.requestResponse({

                data: '' + (++index),
                metadata: 'org.mvnsearch.account.AccountService.findById',
            })**


如何解决上述问题?

slsn1g29

slsn1g291#

如果您在后端使用rsocket路由,那么它是以长度为前缀的。看到了吗https://github.com/rsocket/rsocket-demo/blob/master/src/main/js/app.js#l22-l36级

// Create an instance of a client
  const client = new RSocketClient({
    setup: {
      keepAlive: 60000,
      lifetime: 180000,
      dataMimeType: 'application/json',
      metadataMimeType: 'message/x.rsocket.routing.v0',
    },
    transport: new RSocketWebSocketClient({url: url}),
  });

  const stream = Flowable.just({
    data: '{"join": {"name": "Web"}}',
    metadata: String.fromCharCode('chat/web'.length) + 'chat/web',
  });

路由规范允许多条路由,因此不幸的是,单个路由的编码会因此而变得复杂。https://github.com/rsocket/rsocket/blob/master/extensions/routing.md

相关问题