Coder Social home page Coder Social logo

Improve timeout mechanisms about ruby-mqtt HOT 5 OPEN

njh avatar njh commented on May 20, 2024
Improve timeout mechanisms

from ruby-mqtt.

Comments (5)

balwantk avatar balwantk commented on May 20, 2024

@njh what action does one take if at all it has hung?

from ruby-mqtt.

njh avatar njh commented on May 20, 2024

It should send a disconnect packet and then close the TCP socket.

from ruby-mqtt.

balwantk avatar balwantk commented on May 20, 2024

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.

Vincent14 avatar Vincent14 commented on May 20, 2024

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.

softwaregravy avatar softwaregravy commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.