asterisk-hass-integration icon indicating copy to clipboard operation
asterisk-hass-integration copied to clipboard

Integration started before Asterisk addon fails to connect

Open pluskal opened this issue 2 years ago • 2 comments

During a full system reboot, it happens that this integration starts before the asterisk addon, resulting in the following error.

This error originated from a custom integration.

Logger: custom_components.asterisk
Source: custom_components/asterisk/__init__.py:154
Integration: Asterisk (documentation, issues)
First occurred: 9:09:18 AM (1 occurrences)
Last logged: 9:09:18 AM

Error connecting to Asterisk: Connection refused

Would it be possible to use retry logic to overcome this?

A workaround seems to be to restart Home Assistant after the addon starts.

pluskal avatar Sep 18 '22 07:09 pluskal

Yes this is a known issue, that should be fixed by retrying to connect. But the library used has a bug that makes that impossible. So I'm gonna switch to a new maintained library, just haven't got around to it.

TECH7Fox avatar Sep 18 '22 09:09 TECH7Fox

Will be fixed by #57

TECH7Fox avatar Sep 18 '22 09:09 TECH7Fox

For startup this got fixed. The integration now retries startup until it connects. It still crashes if it disconnects after startup, but you can manually reload it for now. Let me know if you got any issues left.

TECH7Fox avatar Dec 17 '22 00:12 TECH7Fox

I have somewhat similar situation but since there is no other post about it I will detail it here. The add-on does not connect and the error is:

Connection error while connecting to localhost:5038: Connection refused When dumping the log I get the following:

[homeassistant.config_entries] Config entry 'localhost' for asterisk integration not ready yet: Connection error while connecting to localhost:5038: Connection refused; Retrying in background

Sometimes it works after a HA restart OK but most of the time it does not. It usually happens after an HA Core update is being performed and after the HA restart it is stuck in this state.

niraviry avatar Dec 24 '22 19:12 niraviry

@niraviry are you restarting the add-on? Then it crashes and you need to manually reload the integration for now. But when restarting the entire HA, it should retry until succeeding.

Do you have the latest version of the integration?

TECH7Fox avatar Dec 24 '22 21:12 TECH7Fox

I do have the latest version and it is true for all last 4 versions or so.

niraviry avatar Dec 25 '22 19:12 niraviry

Any suggestions?

niraviry avatar Dec 27 '22 18:12 niraviry

@niraviry it's weird. Normally the integration should only stop working when the add-on is restarting, not the other way around. Is there anything in the asterisk logs?

TECH7Fox avatar Dec 27 '22 21:12 TECH7Fox

HA logs while filtering for Asterisk in the main log shows the above error twice and that's it. Don't mind the Hebrew. It is just the date. It is still in the same state for a few days. It might fix itself whenever it fills. If choosing Asterisk from the side list of integrations and add-ons, no errors at all.

Any other location to get the log?

Logger: homeassistant.config_entries Source: config_entries.py:1113 First occurred: 24 בדצמבר 2022 בשעה 19:35:07 (6 occurrences) Last logged: 26 בדצמבר 2022 בשעה 13:33:48

Config entry 'localhost' for asterisk integration not ready yet: Connection error while connecting to localhost:5038: Connection refused; Retrying in background

niraviry avatar Dec 28 '22 18:12 niraviry

Just rebooted HA again due to other reseaon (LG Integration update) and now it is OK.

niraviry avatar Dec 28 '22 18:12 niraviry