Giter VIP home page Giter VIP logo

umqtt_async's People

Contributors

thebasti0n avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

umqtt_async's Issues

check_for_messages res evaluates to 49 or 50

Thanks for a great async MQTT implementation. I particularly like the decoupling from wifi/networking. I have got this working nicely on a RP Pico W connecting to Mosquitto. I had a slight issue on connecting. The on_connection_cb kept firing repeatedly in connect(). It was due to message_handler() -> check_for_messages() setting is_connected to False when res = 49 or 50. This in turn causes keep_alive_task to break out of the while loop. I simply removed:

else:
raise OSError(-1)

I'm not sure what codes 49 or 50 are??

self.loop.create_task(self.message_handler()) # Tasks quit on connection fail.
self.loop.create_task(self.keep_alive_task())
->
async def message_handler(self):
try:
while self.is_connected:
await self.check_for_message()
except OSError:
pass
self.is_connected = False
->
res = await self.read(1)
if res == b'':
return None
res = res[0]

# res = 49 or 50

->

else:
raise OSError(-1)
->
async def keep_alive_task(self):
while self.is_connected:
if ticks_diff(ticks_ms(), self.last_message_received) >= (self.keep_alive*1000/2):
try:
await self.ping()
except OSError:
break
await asyncio.sleep(1)
self.is_connected = False

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.