DEV Community

Discussion on: Getting Started With RSocket Part 2

Collapse
 
ramureddymca profile image
ramureddymca

Thanks you for nice tutorial, but how can we close connection in Request-stream scenario ? between client and server ?

Collapse
 
mydeveloperplanet profile image
mydeveloperplanet

Thank you for the comment. It is a good question. I have added a close method now in the RSocketClientController:

@GetMapping("/close")
public void close() {
    rSocketRequester.rsocketClient().dispose();
}
Enter fullscreen mode Exit fullscreen mode

I hope this answers your question.

Collapse
 
ramureddymca profile image
ramureddymca

Thank you so much, the above code is working fine to close connection.

But if I try to invoke again, getting below error for "request-response"

java.util.concurrent.CancellationException: Disposed.

Is it possible to stop stream the data without closing the connection for request- stream scenario?

Thread Thread
 
mydeveloperplanet profile image
mydeveloperplanet

I do not know, I have spent some time searching for a solution, but did not find any. I have found that calling dispose is the way to stop the stream. But I could not find how to reestablish the connection. During my research for the blogs, I had difficult times to find good documentation for rsocket, certainly when trying to solve problems. If you are able to find the answer to your question, I would like to know it also ;-)