admin管理员组文章数量:1278880
I changed deprecated connectWebSocket(url) into websocket(url)
See example I am using here:
Problem: the given alternative, websocket(url), results in null pointer of the rsocket requester.rsocket(), why?
See pls code
@SpringBootApplication
@Slf4j
@AllArgsConstructor
public class RsocketDemoClientApplication implements CommandLineRunner {
private static final String CLIENT_ID = UUID.randomUUID().toString();
private final RSocketRequester rSocketRequester;
private final RSocketRequester.Builder rsocketRequesterBuilder;
public static void main(String[] args) throws Exception {
SpringApplication.run(RsocketDemoClientApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
MimeType SIMPLE_AUTH =
MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString());
UsernamePasswordMetadata credentials =
new UsernamePasswordMetadata(“user”, “secret”);
URI url = URI.create("ws://localhost:7000");
SocketAcceptor responder = RSocketMessageHandler.responder(rSocketRequester.strategies(), new EventStreamHandler());
RSocketRequester requester = rsocketRequesterBuilder
.setupRoute("client-connect")
.setupData(CLIENT_ID)
.setupMetadata(credentials, SIMPLE_AUTH)
.rsocketStrategies(builder ->
builder.encoder(new SimpleAuthenticationEncoder()))
.rsocketConnector(connector -> connector.acceptor(responder))
.websocket(url);
//.connectWebSocket(url) -> old one that works but deprecated
//.block();
requester.rsocket()// -> rsocket() = null why?
.onClose()
.doOnError(error -> log.warn("Connection CLOSED"))
.doFinally(consumer -> log.info("Client DISCONNECTED"))
.subscribe(response -> log.info("client-connect server response {}", response));
}
}
本文标签: javaCalling RSocketclient from RSocketserver but requesterrsocket() is null whyStack Overflow
版权声明:本文标题:java - Calling RSocket-client from RSocket-server but requester.rsocket() is null why? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741275670a2369715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论