rsocket / rsocket-js

JavaScript implementation of RSocket
https://github.com/rsocket/rsocket-js
Apache License 2.0
602 stars 97 forks source link

RSocket and transport out of sync #140

Open chacent opened 3 years ago

chacent commented 3 years ago

i have a rsocket instance

when i call requestChannel without any data send, actually request(on the other side) won't be occured.

similar when transport of the rsocket has been gone,and call requestChannel , the subscribe (on the local side) occured where i just want some error been raised

OlegDokuka commented 3 years ago

Hi @chacent!

Thank you for writing. Do you have any core which reproduces the issue? Also, can you specify the RSOcket-Js version you have this issue reproducible?

In general, this was fixed by https://github.com/rsocket/rsocket-js/pull/117

chacent commented 3 years ago

thanks for answer,i used v0.0.25

const { RSocketServer , BufferEncoders,RSocketClient } = require('rsocket-core');
const RSocketTCPServer = require('rsocket-tcp-server').default;
const  RSocketTCPClient = require('rsocket-tcp-client').default;
const {Flowable} = require('rsocket-flowable');

new RSocketServer({
    transport:new RSocketTCPServer({port: 80}, BufferEncoders),
    getRequestHandler(rsocket, payload){
        let subscriber;
        rsocket.requestChannel(new Flowable(subscriber=>{
            subscriber.onSubscribe({
                request: (n) => {
                    console.log('request occured');
                    // @bug if i don't call onNext, client will not receive request channel
                    // subscriber.onNext({data:Buffer.alloc(0)});
                    debugger
                },
                cancel(){
                    debugger
                }
            });
        })).subscribe({
            onComplete: () => console.log('complete'),
            onError: err => console.log(err),
            onNext:x=>{
                console.log(x.data);
                subscriber.request(1);
            },
            onSubscribe: x =>{
                subscriber = x;
                subscriber.request(1);
            }
        });
    }
}).start();

(async(options)=>{
    const client = await new RSocketClient({
        setup: {
            dataMimeType: 'text/plain',
            keepAlive: 10000,
            lifetime: 86400000,
            metadataMimeType: 'text/plain'
        },
        transport: new RSocketTCPClient({
            host: options.host,
            port: options.port,
        }, BufferEncoders ),
        responder:{
            requestChannel(flowable) {
                console.log('got request');
                debugger// forget return value,just for sample
            }
        }
    }).connect();
})({
    port: 80,
});
chacent commented 3 years ago

and i want to know how i can get current state of rsocket , except for subscribe connectStatus,there is no event style mechanism?