1

I now receive an rsocket connection in my spring project, and then I want to get its remote address and port, how should I get it?Similar to using socket.getRemoteSocketAddress() to get the remote address of the socket.

@ConnectMapping
public void connectMapping(RSocketRequester requester) {
    // there is a resockt connect, how can i get the remote host from it
    RSocket rSocket = requester.rsocket();
    // TODO
    logger.info("host port");
}
Yu Wang
  • 11
  • 2

1 Answers1

0

Unfortunately, I think even if you grab the RSocketRequester in @ConnectMapping or @MessageMapping method it is an internal detail. io.rsocket.core.RSocketRequester via RequesterResponderSupport holds the DuplexConnection which represents a connection over tcp, web socket or in-process. It is not exposed via a public API.

This is a worthy request but you will need to file a feature request to get this added unless I'm missing something obvious.

It isn't clear that there is a hook in https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/api/org/springframework/boot/rsocket/server/RSocketServerCustomizer.html to let you see the DuplexConnection (tcp or web socket etc) as it's established.

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
  • Thank you for your answer! Indeed, as you answered, the connected information is protected. It would be troublesome if I want to check the remote address. – Yu Wang Mar 03 '21 at 11:02