Comments (5)
@njh what action does one take if at all it has hung?
from ruby-mqtt.
It should send a disconnect packet and then close the TCP socket.
from ruby-mqtt.
In the name of fault tolerance, wouldn't it be better to:
- Send a ping, wait 10 seconds for a resp.
- If resp great.
- If no resp, disconnect, and try to reconnect a few times.
- If it works, and we get a resp good.
- Else close the connection and raise like a
MQTT::ConnectionError
.
Your thoughts?
-Balwant
from ruby-mqtt.
The ping behaviour is bandwidth consumer, such some device should avoid. See this MQTT explanation about Keep Alive mechanism in the protocol spec: https://www.hivemq.com/blog/mqtt-essentials-part-10-alive-client-take-over/
Resume: "If the client does not send a messages during the keep-alive period, it must send a PINGREQ packet to the broker to confirm that it is available and to make sure that the broker is also still available."
from ruby-mqtt.
coming in 10 years later with a use case ...
We use this on the server, and we are unconcerned with bandwidth. I have observed that we get "stale" connections. I don't know how else to describe it, but we are sitting in the get
method, but the mqtt server stops sending us messages. As the control-server, we want to ensure we have an active connection that is just quiet, so being able to ping every X seconds and assume dead if no response would be really valuable.
I agree that you probably wouldn't want bandwidth constrained end-devices to leverage this behavior.
from ruby-mqtt.
Related Issues (20)
- Unable to authenticate HOT 16
- Websocket support HOT 5
- Error OpenSSL alert unknown ca HOT 1
- MQTT client on weak CPU and high traffic environment
- background client
- SSL connection failing due to optimisations in PR #134 HOT 6
- I have renamed the 'master' branch to 'main'
- Drop support for ruby 1.9 HOT 2
- unable to establish QoS1 sessions
- Thread termination with exception not handled? HOT 7
- Release plan HOT 14
- Error: can't modify frozen OpenSSL::SSL::SSLContext HOT 1
- How to handle sigterm? HOT 2
- supporting private keys other than RSA
- Need help? HOT 1
- Remove autoload HOT 1
- Is using a connection Pool Recommended?
- Major issue while using Thread to catch exception
- ruby-mqtt-271ee631f128/lib/mqtt/packet.rb:223:in `read_byte': Failed to read byte from socket (MQTT::ProtocolException)
- Support for MQTT 5 HOT 2
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 ruby-mqtt.