Closed shipra0278 closed 2 years ago
Updating myRxStompConfig
in beforeConnect
does not alter the rxStomp
. Please try changing
myRxStompConfig.reconnectDelay = 500 * Math.pow(2, currentTry);
to
rxStomp.configure({reconnectDelay: 500 * Math.pow(2, currentTry)});
In addition, you should reset currentTry
on a successful connection.
Ok, thanks.
Also, when I configure the WebSocket with URL "ws://amq.net:30007/ws", I get error. but if I if set the brokerURL with same URL "ws://amq.net:30007/ws" in config file. It was fine.
myRxStompConfig.webSocketFactory = function () { return new WebSocket("ws://amq.net:30007/ws"); //return new SockJS(//'http://localhost:7777'); };
ERROR: Thu Aug 18 2022 08:26:06 GMT-0500 (Central Daylight Time) 'Opening Web Socket...' rx-stomp-service-factory.ts:15 WebSocket connection to 'ws://amq.........net:30007/ws' failed: _config_rx_stomp_config__WEBPACK_IMPORTED_MODULE_1__.myRxStompConfig.webSocketFactory @ rx-stomp-service-factory.ts:15 _createWebSocket @ client.js:278 (anonymous) @ client.js:211 fulfilled @ client.js:4 invoke @ zone.js:372
rx-stomp.config.ts:29 Thu Aug 18 2022 08:26:06 GMT-0500 (Central Daylight Time) 'Connection closed to undefined' rx-stomp.config.ts:29 Thu Aug 18 2022 08:26:06 GMT-0500 (Central Daylight Time) 'STOMP: scheduling reconnection in 8000ms'
Thanks Shipra
Glad to know it worked. I will close this issue.
I have requirement in Angular to use websocket to get real time updates for the data grid from Active MQ. I used Websocket to do this and need to subscribe to "topics". I followed https://stomp-js.github.io/guide/rx-stomp/rx-stomp-with-angular.html and created ConfigurationPermalink RxStompServicePermalink Factory to create and initialize RxStompServicePermalink
Everything works fine. Requirment: Now we need to check on the max attempt(4) to reconnect and reset the reconnect delay for every attempt.
I coded in the rxStompServiceFactory. as below, please guide me the following code is correct or is there any better way?