Detect closed server connection and automatically reconnect.
See original GitHub issueI have a simple setup between two services that I’ve built from provided examples. I have one service that listens for incoming connections:
TcpServerTransport tcp = TcpServerTransport.create(configProps.getPort());
RSocketFactory.receive()
.acceptor(itemSocketAcceptor)
.transport(tcp)
.start().log()
.subscribe();
Another service attempts to make a connection:
this.socket = RSocketFactory
.connect()
.transport(TcpClientTransport.create(<host>, <port>)
.start()
.block();
If I redeploy the receiving service, the client service never reports an error (unless I set a timeout on the requestResponse method). I can’t seem to find a way for the client side to detect that the underlying connection has closed and to automatically try to reconnect. To boot, these are web applications in Spring Boot, so I’m never able to attempt to call block() during a web request.
The onClose
method seems to be an indicator that the connection has closed, but I’m not sure how to use that in the context of a web request to be able to attempt to rebuild the connection which necessarily requires me to call block
.
Not sure if this is an actual issue or if I’ve simply overlooked some documentation or examples. I’m anxious to adopt rsocket in my company, so any direction would be greatly appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:27 (14 by maintainers)
Top GitHub Comments
@mostroverkhov I believe that is correct. Before using the load balancer, there never seemed to be an error on the client side if the server was restarted; it would just hang (seemingly indefinitely). If I set a timeout on the request, I would see the timeout exception, but I could not find any good way to tell the client to attempt to reconnect after the server side had restarted.
I was using
roscket-core
andrsocket-transport-netty
0.11.7 and just noticed that I was usingrsocket-load-balancer
0.11.8. 0.11.9 does not appear to be on maven central. I’ll update everything to 0.11.8 and restest/reverify the issue.@joshfix Don’t block on the loadbalancer - you need to subscribe to it each time so it can load balance and what not.
Should be more like this: