Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestResponse (as client) ignores complete #78

Open
freelancer1845 opened this issue Mar 18, 2020 · 1 comment
Open

RequestResponse (as client) ignores complete #78

freelancer1845 opened this issue Mar 18, 2020 · 1 comment
Assignees
Labels
needs triage Issue/PR needs triage by a project maintainer

Comments

@freelancer1845
Copy link

freelancer1845 commented Mar 18, 2020

Hey,

I'm trying to use RequestResponse with Spring Boot as RSocketServer.

I have a Controller Method like this:

@MessageMapping
public Mono<Void> request() {
    return Mono.empty();
}

My Request in ts looks like this (the socket actually comes from another subject... but it is the reactivesocket received from the "connect" method):

public requestResponse<T>(route: string, payload: any = {}): Observable<T> {
      let disposer;

      return new Observable<T>((subscribe) => {
        try {
          socket.requestResponse({
            data: payload,
            metadata: String.fromCharCode(route.length) + route
          }).subscribe(
            {
              onComplete: (payload) => {
                console.log("Request Complete. Payload: " + payload)
                // if (payload) {
                //   subscribe.next(payload.data);
                // }
                subscribe.complete();
              },
              onError: (error) => {
                console.log("Error: " + error);
              },
              onSubscribe: (disposer) => {
                console.log("Subscribing")
                disposer = disposer;
              }
            }
          )
          return () => {
            if (disposer) {
              disposer();
            }
          }
        } catch (err) {
          subscribe.error(err);
        }
      });
    }));
}

The Message reaches the controller method and no errors are logged inside spring boot.
I guess the problem is, that the returned Frame is a Payload frame without the "next" flag but with the "complete" flag. Because of that "RSocketMachine.js:717" never calls onNext(...) which would complete the requestResponse interaction. In "RSocketMachine.js:316" "onComplete" is set to an emptyfunction.

Is that correct?

My fix is to change RSocketMachine.js:315-319 to this

let value = null;
this._receivers.set(streamId, {
    onComplete: () => subscriber.onComplete(value),
    onError: error => subscriber.onError(error),
    onNext: data => value = data,
});

of course this now emits null as value in the single which is probably not wanted^^

@kevinat
Copy link

kevinat commented Jul 8, 2021

@OlegDokuka
Is there any plan to fix this? May be make Single subscriber have an onNext is better way, but may cause breaking change.

@viglucci viglucci added the needs triage Issue/PR needs triage by a project maintainer label Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue/PR needs triage by a project maintainer
Projects
None yet
Development

No branches or pull requests

4 participants