stomp-js / rx-stomp

STOMP adaptor for RxJS
Apache License 2.0
112 stars 21 forks source link

RxStomp - Not receiving any responses from watch subscription #553

Open Ph4nt0mx4 opened 1 month ago

Ph4nt0mx4 commented 1 month ago

Hello!

I have an unusual problem with my WebSocket connection. I have created a WebSocket configuration and connection using RxStomp. While the connection itself works, and my backend recognizes that I'm connected, I am not receiving any messages from the backend despite being subscribed with .watch.

Here is my config

import { RxStompConfig } from '@stomp/rx-stomp';
import { environment } from '../../environments/environment';
import SockJS from 'sockjs-client';

export const rxStompConfig: RxStompConfig = {
  webSocketFactory: () => {
    return new SockJS(`${environment.ws}`);
  },

  heartbeatIncoming: 0,
  heartbeatOutgoing: 20000,
  reconnectDelay: 200,
  logRawCommunication: true,

  debug: (msg: string): void => {
    console.log('rxStomp console:', new Date(), msg);
  },
};

Here is the RxStomp service factory:

import { RxStompService } from './rx-stomp.service';
import { rxStompConfig } from './rx-stomp.config';

export function rxStompServiceFactory() {
  const rxStomp = new RxStompService();
  rxStomp.configure(rxStompConfig);
  rxStomp.activate();
  return rxStomp;
}

And in the component where I want to receive messages, I have the following code:

this.rxStompService.watch({ destination: `/destinedPath/${id}` }).subscribe(
  msg => {
    console.log('rxStompService msg body: ', msg.body);
    console.log('rxStompService msg: ', msg);
  },
  err => {
    console.log(err);
  }
);

As mentioned, the network and console indicate that the connection is valid, yet I do not receive any messages. Can anyone please help me?