0

我的 Spring boot 充当 rsocket 服务器。
spring-boot-starter-rsocket v2.5.2 和 spring-boot-starter v 2.5.2

应用程序有一个像这样的控制器 -

 @MessageMapping("request.stream")
    public Flux<String> requestStream(@Payload String userInfo) throws JsonProcessingException {
        Flux<TaskBrief> publishedEvents = Flux.create(taskUpdateNoticeConsumer).publish().autoConnect();        

     // have tried Flux.create().share() as well

    //    publishedEvents= Flux.create(taskUpdateNoticeConsumer).share();
   
        return publishedEvents.map(taskEvent -> {
          ...
         

        });
   

和rocket-js(v0.0.23)像这样连接并订阅websocket

有关配置的详细信息.......................................... ......................

export const RsocketTaskListClient = () => {

  const client = new RSocketClient({
    transport: new RSocketWebSocketClient(
      {
        url: 'ws://localhost:8097/rsocket',
        wsCreator: (url: string) => new WebSocket(url),
        debug: true,
      }
    ),
    setup: {
      dataMimeType: "text/plain",
      metadataMimeType: 'message/x.rsocket.routing.v0',
      keepAlive: 60000,
      lifetime: 180000,
    }
  });
  const showUpdates = useCallback((msg) => {
    // Update the list
   
  }, []);
  

  useEffect(() => {        
    async function initRsocketConnection() {
      await client.connect().subscribe({        
       
        onComplete: socket => {
          socket.requestStream({
            data: "jsclient",
            metadata: String.fromCharCode("request.stream".length) + "request.stream"
          })
            .subscribe({
              onNext: (data: Payload<unknown, unknown>) => {
                ........
              },
              onError: ........,
              onSubscribe: sub => {
                sub.request(2147483647);
              }
            });
        }
      });
    }

    console.log(" calling initRsocketConnection function");
    initRsocketConnection();
    return () => {
      console.debug('will disconnect from rsocket');
      client.close();
    }
  }, [showUpdates])

  return (
    <div>rsocket web client component</div>
  )

}
  
Problem   

Js client connects and receives messages from spring controller.  But when i refresh the browser then  connection is established but it stops receiving messages.  On the server side, i see that FluxSink.next method is getting called.   
Please advice how to fix this issue.
4

0 回答 0