RSocket error 0x201 (APPLICATION_ERROR): readerIndex(1) + length(102) exceeds writerIndex(8): UnpooledSlicedByteBu

467 Views Asked by At
 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)

enter image description here

enter image description here

trying to connect to spring rsocket using reactjs. getting an error before subscribe in the javascript code shown below.

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

enter image description here

How to resolve the above issue?

1

There are 1 best solutions below

3
On BEST ANSWER

If you are using rsocket routing on the backend, it is length prefixed. See 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',
  });

The routing specification allows multiple routes, so the encoding of a single route is unfortunately complicated by this. https://github.com/rsocket/rsocket/blob/master/Extensions/Routing.md