Comments (4)
Apparently the same thing also happens in a scenario where a connection + login has succeeded but the channel pool has minFreeChannels
> 0, for example if channelFactory
in the gist is replaced by:
var channelFactory = new stompit.ChannelPool(connections, {
minFreeChannels: 1,
});
...as well as servers.connectHeaders
set up so that the connection + login actually succeeds.
from stompit.
Here are the series of commits that fix the problems raised in this issue:
- 97e2d86 Add support for aborting reconnect
- 2a1b056 Abort pending connect on channel disconnect
- 84b6d4c Add ChannelPool#close method
- 1492a45 Clear timeout when destroy method is called on a connecting socket
- 3151f42 Destroy transport socket on connect abort
In summary, closing a channel aborts the reconnect occurring in ConnectFailover, and a close method has been added to ChannelPool class that closes any free channels.
In the scenario where you're using a ChannelPool, you need extra signal handlers to shutdown the channel pool.
var closeChannelPool = channelPool.close.bind(channelPool);
process.on("SIGINT", closeChannelPool).on("SIGTERM", closeChannelPool);
from stompit.
Thanks for looking into this, and the fixes.
Maybe I'm missing something wrt the ChannelPool scenario, but code in this gist still does not shut down gracefully on Ctrl-C when there's nothing listening on localhost:61613: https://gist.github.com/scop/aae8d5c3411d1cc92c72
from stompit.
In my test I had signal handlers for the channel pool and the channel in use, and in the nothing-listening scenario the process terminates immediately after SIGINT. Your code needs a signal handler inside the channelPool.channel callback, and it should only exist for as long as the channel is in use.
Closing the channel pool only closes the current free channels and channels that are later reclaimed. Responsibility to close an occupied channel falls on the user. I now realise this behaviour breaks a key feature of the channel pool, is going to make channels awkward to use and it will probably encourage improper use of channel close. Therefore I intend to change channel pool close so that it closes all channels.
In your code there is a call to close the channel in the send callback - this call is unnecessary and is improper use of channel close. Once the send is complete the channel will be automatically reclaimed by the pool. If a channel is used for a subscription then the channel remains occupied until the user calls unsubscribe. A channel is reclaimed by the pool when all sends and subscribes have finished. A channel user shouldn't be concerned with closing the channel or disconnecting the underlying client.
from stompit.
Related Issues (20)
- Error: Unexpected ACK received for message-id. How to resolve? HOT 2
- Bulk processing HOT 2
- Cannot send any message when applying the heavy load in sequential in for loop
- Connection refused 127.0.0.1:61613 HOT 3
- How to remove activemq queues and scheduled jobs?
- How to get scheduled id from client when scheduling message to activemq?
- How to set type in message headers
- Unable to use priority in activeMq using stompit in nodejs HOT 1
- Use of Heartbeat in activeMQ HOT 1
- Message gets redelivered in loop during the time of high CPU processing on the client side HOT 3
- Is there a way to programmatically delete an ActiveMQ Job Schedule? HOT 1
- Disconnect hangs after unsubscribe HOT 1
- The connection is closing when thousands of messages are ready to subscribe in queue HOT 1
- Max size of message
- Setting AMQ_SCHEDULED_DELAY doesn't work
- Async usage?
- Cannot read properties of undefined (reading 'send')
- Get properties of message
- How to keep the connection open and also set connection timeout?
- A NACK call incorrectly results in an ACK on the server side
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 stompit.