mrk-its / homeassistant-blitzortung

Custom Component for fetching lightning data from blitzortung.org
MIT License
186 stars 38 forks source link

Failed to connect to MQTT server #99

Closed chma73 closed 2 months ago

chma73 commented 2 months ago

Hello, just installed blitzortung 1.3.3 on HA Core 2024.5.0, configuration as described in the manual. But it's not working, in the log I got this failure. Can anyone help me fix the error?

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.blitzortung.mqtt Quelle: custom_components/blitzortung/mqtt.py:145 Integration: Blitzortung (Dokumentation, Probleme) Erstmals aufgetreten: 2. Mai 2024 um 18:37:09 (2 Vorkommnisse) Zuletzt protokolliert: 2. Mai 2024 um 19:21:46

Failed to connect to MQTT server due to exception: [Errno 111] Connection refused

astrosteve0 commented 2 months ago

Same here, mine has not been working the last few days, here's the error in the Home Assistant log:

Exception in _on_connection_change when dispatching 'blitzortung_mqtt_connected': () Traceback (most recent call last): File "/config/custom_components/blitzortung/init.py", line 222, in _on_connection_change sensor.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state self.hass.verify_event_loop_thread("async_write_ha_state") File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread frame.report( File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report _report_integration(what, integration_frame, level, error_if_integration) File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration raise RuntimeError( RuntimeError: Detected that custom integration 'blitzortung' calls async_write_ha_state from a thread at custom_components/blitzortung/init.py, line 222: sensor.async_write_ha_state(). Please report it to the author of the 'blitzortung' custom integration. Exception in _on_connection_change when dispatching 'blitzortung_mqtt_disconnected': () Traceback (most recent call last): File "/config/custom_components/blitzortung/init.py", line 222, in _on_connection_change sensor.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state self.hass.verify_event_loop_thread("async_write_ha_state") File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread frame.report( File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report _report_integration(what, integration_frame, level, error_if_integration) File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration raise RuntimeError( RuntimeError: Detected that custom integration 'blitzortung' calls async_write_ha_state from a thread at custom_components/blitzortung/init.py, line 222: sensor.async_write_ha_state(). Please report it to the author of the 'blitzortung' custom integration.

mrk-its commented 2 months ago

@astrosteve0 are you on last version (1.3.3)?

astrosteve0 commented 2 months ago

When the problem first happened, I noticed there was an update in HACS, and I updated it. Currently HACS is not showing any new updates, and I am on version 1.3.2 according to HACS. In Home Assistant itself, it says I am running version 1.3.1. That seems weird. I tried restarting HA, and now HACS shows the 1.3.3 update, I loaded that. I restarted again, and the issue is now fixed. Although in HA, it still shows it running version 1.3.1: Blitzortung

chma73 commented 2 months ago

Hello @mrk-its, have you an idea / solution for my problem?

mrk-its commented 2 months ago
  1. The mqtt host is blitzortung.ha.sed.pl, can you ping it?
  2. mqtt port is 1883, can you connect to it? on linux you can do:
    $ nc -v blitzortung.ha.sed.pl 1883
    Connection to blitzortung.ha.sed.pl (35.158.104.63) 1883 port [tcp/*] succeeded!
  3. Try to restart HA, maybe it will be able to reconnect

For now there are over 7k users connected, I also can reconnect without any problems, so it must be something on your end.

chma73 commented 2 months ago

Hello @mrk-its, thanks for your hint's. Is only the port 1883 necessary? Seems that my firewall blocks the communication

mrk-its commented 2 months ago

Yes, port 1883 should be enough