ecowitt2mqtt icon indicating copy to clipboard operation
ecowitt2mqtt copied to clipboard

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

Open bachya opened this issue 1 year ago • 11 comments

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 https://github.com/bachya/ecowitt2mqtt/issues/1024

Checklist:

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

bachya avatar Jul 11 '24 03:07 bachya

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (7eae99f) to head (e6a4102). Report is 100 commits behind head on dev.

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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 11 '24 17:07 codecov[bot]

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

jwillmer avatar Jul 18 '24 11:07 jwillmer

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

bachya avatar Jul 18 '24 13:07 bachya

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 avatar Jul 18 '24 20:07 jwillmer

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

jwillmer avatar Jul 19 '24 07:07 jwillmer

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 avatar Jul 19 '24 13:07 bachya

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.

bachya avatar Aug 02 '24 22:08 bachya

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

jwillmer avatar Aug 05 '24 13:08 jwillmer

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.

bachya avatar Aug 05 '24 13:08 bachya

There hasn't been any activity on this pull request recently, so it has automatically been marked as stale and will be closed if no further action occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Sep 05 '24 08:09 github-actions[bot]

There hasn't been any activity on this pull request recently, so it has automatically been marked as stale and will be closed if no further action occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Oct 07 '24 08:10 github-actions[bot]

There hasn't been any activity on this pull request recently, so it has automatically been marked as stale and will be closed if no further action occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Nov 08 '24 08:11 github-actions[bot]