Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to configure MQTT message and session expiry intervals #1037

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

bachya
Copy link
Owner

@bachya bachya commented Jul 11, 2024

Describe what the PR does:

Background: https://www.hivemq.com/blog/mqtt5-essentials-part4-session-and-message-expiry/

Does this fix a specific issue?

Fixes #1024

Checklist:

  • Confirm that one or more new tests are written for the new functionality.
  • Run tests and ensure everything passes (with 100% test coverage).
  • Update README.md with any new documentation.

@bachya bachya added the enhancement Enhancement of the code, not introducing new features. label Jul 11, 2024
@bachya bachya self-assigned this Jul 11, 2024
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7eae99f) to head (e6a4102).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #1037   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           32        32           
  Lines         1775      1805   +30     
=========================================
+ Hits          1775      1805   +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jwillmer
Copy link

Is this code available as a docker container? Then I could test it on my setup.

@bachya
Copy link
Owner Author

bachya commented Jul 18, 2024

Is this code available as a docker container? Then I could test it on my setup.

https://github.com/bachya/ecowitt2mqtt/pkgs/container/ecowitt2mqtt/242520435?tag=pr-1037

@jwillmer
Copy link

it did not report me the message once i reconnected. but i need to check if all services are using the latest protocol. Would be good we get a second validation.

@jwillmer
Copy link

Today it crashed with this message. My broker supports MQTT5 and I did not modify my env variables since you use already good defaults.

2024-07-18 22:50:07,952 | ERROR | <class 'ValueError'> exception caused a shutdown: Properties only apply to MQTT V5
Traceback (most recent call last):
  File "/venv/lib/python3.11/site-packages/ecowitt2mqtt/runtime.py", line 114, in create_loop
    async with Client(
  File "/venv/lib/python3.11/site-packages/aiomqtt/client.py", line 707, in __aenter__
    await loop.run_in_executor(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1431, in connect
    raise ValueError("Properties only apply to MQTT V5")
ValueError: Properties only apply to MQTT V5

@bachya
Copy link
Owner Author

bachya commented Jul 19, 2024

Today it crashed with this message. My broker supports MQTT5 and I did not modify my env variables since you use already good defaults.


2024-07-18 22:50:07,952 | ERROR | <class 'ValueError'> exception caused a shutdown: Properties only apply to MQTT V5

Traceback (most recent call last):

  File "/venv/lib/python3.11/site-packages/ecowitt2mqtt/runtime.py", line 114, in create_loop

    async with Client(

  File "/venv/lib/python3.11/site-packages/aiomqtt/client.py", line 707, in __aenter__

    await loop.run_in_executor(

  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run

    result = self.fn(*self.args, **self.kwargs)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1431, in connect

    raise ValueError("Properties only apply to MQTT V5")

ValueError: Properties only apply to MQTT V5

Interesting. Perhaps I need to somehow specify the MQTT version when I create a client. I'll investigate.

@bachya bachya force-pushed the bachya/message-session-expiry branch from 2976acf to 2a211fe Compare August 2, 2024 22:10
@bachya
Copy link
Owner Author

bachya commented Aug 2, 2024

Thanks for your patience, @jwillmer. I just pushed new code that allows you to change the version of the MQTT protocol inside ecowitt2mqtt's MQTT client. Once the build finishes, you can pull that same Docker image and try again. You'll use the ECOWITT2MQTT_MQTT_PROTOCOL_VERSION environment variable with a value of 5.

@jwillmer
Copy link

jwillmer commented Aug 5, 2024

That is my output. Sadly something is still broken? I use eclipse-mosquitto:2 docker image and according to the ChatGPT it supports MQTT version 5 out of the box without any additional configuration.

2024-08-05 15:35:06,695 | INFO | Starting ecowitt2mqtt (version 2024.06.2)
2024-08-05 15:35:51,481 | ERROR | <class 'ValueError'> exception caused a shutdown: Properties only apply to MQTT V5
Traceback (most recent call last):
  File "/venv/lib/python3.11/site-packages/ecowitt2mqtt/runtime.py", line 116, in create_loop
    async with Client(
  File "/venv/lib/python3.11/site-packages/aiomqtt/client.py", line 707, in __aenter__
    await loop.run_in_executor(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1431, in connect
    raise ValueError("Properties only apply to MQTT V5")
ValueError: Properties only apply to MQTT V5

@bachya
Copy link
Owner Author

bachya commented Aug 5, 2024

Can I see your verbose-level output when you start ecowitt2mqtt? That message comes from the MQTT client, so I think there's something wrong here vs. with mosquitto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add configuration options for MQTT message and session expiry
2 participants