Comments (9)
There is a delay between calling client.activate
and the actual connection getting established. You have two options:
- Write your code inside
onConnect
. However,onConnect
gets called every time a connection is established (like a reconnect after an error). - Check for Client#connected before calling
publish
.
There is wrapper of this library - https://github.com/stomp-js/rx-stomp - that uses rxjs
. That wrapper supports local queuing of messages if the underlying connection is not there.
from stompjs.
Cool, onConnect is working but while publishing, how do I check what message I'm publishing? using debug I get only ping pong but not the actual message that I'm publishing.
I want to log the message, where is it available?
onConnect: function(frame) { client.publish({ destination: "/topic/t1", body: "Bla Bla" }); console.log("Client connected to", frame.headers.server); console.log(client); },
I just get the content-length as 7 using debut, but not the actual message from subscriber.
from stompjs.
Please try setting https://stomp-js.github.io/api-docs/latest/classes/Client.html#logRawCommunication
from stompjs.
This can be set using config as well.
from stompjs.
Thanks for your help. Why is there no disconnected method? I wanted to configure to handle activemq failover after every thing is set up and started and stopping message delivery in case of activemq failover.
maybe something like:
if(client.disconnected) client.reconnect()
so that the publisher doesn't post if my active mq stops responding.
#client.active is something I found but it is not serving my purpose.
from stompjs.
reconnectDelay: 5000
in the configuration will trigger automatic reconnect in 5000ms. Please see https://stomp-js.github.io/guide/stompjs/2018/06/28/using-stompjs-v5.html#lifecycle-callbacks for different callbacks. In general this article is a good read.
from stompjs.
reconnectDelay
only works if my activemq is not running and I start my producer, it'll tell me it's trying to reconnect. But let's assume a scenario where my activemq is running and my producer is also running and suddenly activemq is stopped. Now the problem is it's trying to reconnect but at the same time it's also publishing to the queue as well.
I need to handle the fail over in a way that once the activemq is disconnected even though publisher is publishing, it should stop publishing and try to reconnect only.
from stompjs.
When the broker disconnects for any reason, https://stomp-js.github.io/api-docs/latest/classes/Client.html#onWebSocketClose will be called and https://stomp-js.github.io/api-docs/latest/classes/Client.html#connected will be set to false
.
Depending on your application needs I can suggest one of the following:
- You can listen for https://stomp-js.github.io/api-docs/latest/classes/Client.html#onWebSocketClose and pause/stop publishing. Listen for https://stomp-js.github.io/api-docs/latest/classes/Client.html#onConnect and resume/start publishing.
- Before attempting to publish check for https://stomp-js.github.io/api-docs/latest/classes/Client.html#connected and publish only if it is
true
.
from stompjs.
Thanks for the replies, for now I've switched to node-stomp and it's working fine for my usage. For my application requirement, stomp-js is not serving my purpose!
from stompjs.
Related Issues (20)
- Stomp isn't publishing the payload
- After Delete the queue Stomp not recreating it. HOT 1
- Typescript Import error
- Failed to compile HOT 8
- Still seeing retry after a successful connection. HOT 1
- Cant receive data from websocket
- ws does not work in the browser. Browser clients must use the native WebSocket HOT 2
- TypeScript 5 claims IStompSocketMessageEvent and MessageEvent are incompatible HOT 3
- .
- Callback when a heartbeat has come or gone
- Pinging on demand HOT 1
- Connection closed when App is killed on Android HOT 1
- react native error: trust anchor for certification path not found, when trying stomp socket connection , i used @stomp/stompjs lib. any way to ignore sign certificate? HOT 1
- One and the same message is perceived as 2, with different ID but with the difference of one number at the end. HOT 3
- How to add httpOnly cookies to connectHeaders HOT 3
- Send a JSON object to the body when publishing HOT 1
- TypeError: WebSocket is not a constructor HOT 1
- Stomp auto make new connect after about 1 minute. HOT 1
- Rx-Stomp Invalid frame header Error
- Connection keep closing on React Native HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stompjs.