Zigbee2MqttAssistant icon indicating copy to clipboard operation
Zigbee2MqttAssistant copied to clipboard

unable to connect to mqtt server

Open bluesailor45 opened this issue 3 years ago • 9 comments

created docker-compse file for mqtt server, zigbee2mqtt and zigbee2mqttserverassistant. docker zigbee2mqtt is succesfully connected to mqtt server, but zigbee2mqttassistant does not connect to mqtt: Tried already different variants to Z2MA_Settings for mqttserver as eg. 127.0.0.1:1883 ,etc but nne did work. Please help.

this is docker-compose file:

version: '3' services: zigbee2mqtt: container_name: zigbee2mqtt image: koenkk/zigbee2mqtt volumes: - ./data:/app/data - /run/udev:/run/udev:ro devices: - /dev/ttyACM0 privileged: true environment: - TZ=Europe/Amsterdam - "homeassistant:true" network_mode: host mqtt: container_name: mqtt-server image: eclipse-mosquitto ports: #- "1883:1883" - "9001:9001"

 zigbee2mqttAssistant:
   image: carldebilly/zigbee2mqttassistant
   container_name: assist
   environment:
     - Z2MA_SETTINGS__MQTTSERVER= mqtt-server
     #- Z2MA_SETTINGS__MQTTUSERNAME={MQTTUSERNAME}
     #- Z2MA_SETTINGS__MQTTPASSWORD={MQTTPASSWORD}
  # Set to your TimeZone when using on Linux https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  # Won't work if you're using the Windows version of the container
     - TZ=Europe/Amsterdam
   ports:
     - 8880:80
   restart: unless-stopped

this is (partial) log of zigbee2mqttassist:

Starting Zigbee2MqttAssistant v0.3.157+Branch.master.Sha.ea388c3bbc2d43c4c9c62f27bb6764911ba4acc9... warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60] Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {97c39648-838d-4fed-950e-b75a1858763f} may be persisted to storage in unencrypted form. Hosting environment: Production Content root path: /app Now listening on: http://[::]:80 Application started. Press Ctrl+C to shut down. (base) kurt@kurt-VG086AA-UUZ-m9770ch ~/Documents/Docker/zigbee2mqtt $ docker logs assist Starting Zigbee2MqttAssistant v0.3.157+Branch.master.Sha.ea388c3bbc2d43c4c9c62f27bb6764911ba4acc9... warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60] Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {97c39648-838d-4fed-950e-b75a1858763f} may be persisted to storage in unencrypted form. Hosting environment: Production Content root path: /app Now listening on: http://[::]:80 Application started. Press Ctrl+C to shut down. warn: Zigbee2MqttAssistant.Services.MqttConnectionService[0] Unable to connect to MQTT server mqtt-server. MQTTnet.Exceptions.MqttCommunicationException: Resource temporarily unavailable ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable at System.Net.Dns.InternalGetHostByName(String hostName) at System.Net.Dns.ResolveCallback(Object context)

bluesailor45 avatar Feb 13 '21 14:02 bluesailor45

I'm getting the same after the last Home Assistant update.

Here's my log

Starting Zigbee2MqttAssistant v0.3.157+Branch.master.Sha.ea388c3bbc2d43c4c9c62f27bb6764911ba4acc9...
warn: Zigbee2MqttAssistant.Services.SettingsService[0]
      Section 'settings' in configuration does not exists. Will use default settings instead.
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
warn: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Unable to connect to MQTT server mqtt.
MQTTnet.Exceptions.MqttCommunicationException: Name or service not known
 ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
   at System.Net.Dns.InternalGetHostByName(String hostName)
   at System.Net.Dns.ResolveCallback(Object context)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
   at System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.DoDnsCallback(IAsyncResult result, MultipleAddressConnectAsyncResult context)
   at System.Net.Sockets.Socket.DnsCallback(IAsyncResult result)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__277_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
   at MQTTnet.Implementations.MqttTcpChannel.ConnectAsync(CancellationToken cancellationToken)
   at MQTTnet.Internal.MqttTaskTimeout.WaitAsync(Func`2 action, TimeSpan timeout, CancellationToken cancellationToken)
   at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at MQTTnet.Adapter.MqttChannelAdapter.WrapException(Exception exception)
   at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Extensions.ManagedClient.ManagedMqttClient.ReconnectIfRequiredAsync()

empatel96 avatar Feb 13 '21 15:02 empatel96

Same issue here, and after clearing my cache, the config settings seem to be broken/missing image

jimmyeao avatar Feb 14 '21 15:02 jimmyeao

Same! Installed from HACS

davisdmg avatar Feb 19 '21 23:02 davisdmg

Me too! Configuration is just at once completely empty, and I can not find a good example how it should look (i am running the hassio -?- add on). This is my log:

Starting Zigbee2MqttAssistant v0.3.157+Branch.master.Sha.ea388c3bbc2d43c4c9c62f27bb6764911ba4acc9...
warn: Zigbee2MqttAssistant.Services.SettingsService[0]
      Section 'settings' in configuration does not exists. Will use default settings instead.
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
warn: Zigbee2MqttAssistant.Services.MqttConnectionService[0]
      Unable to connect to MQTT server mqtt.
MQTTnet.Exceptions.MqttCommunicationException: Name or service not known
 ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
   at System.Net.Dns.InternalGetHostByName(String hostName)
   at System.Net.Dns.ResolveCallback(Object context)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
   at System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.DoDnsCallback(IAsyncResult result, MultipleAddressConnectAsyncResult context)
   at System.Net.Sockets.Socket.DnsCallback(IAsyncResult result)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__277_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
   at MQTTnet.Implementations.MqttTcpChannel.ConnectAsync(CancellationToken cancellationToken)
   at MQTTnet.Internal.MqttTaskTimeout.WaitAsync(Func`2 action, TimeSpan timeout, CancellationToken cancellationToken)
   at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at MQTTnet.Adapter.MqttChannelAdapter.WrapException(Exception exception)
   at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Extensions.ManagedClient.ManagedMqttClient.ReconnectIfRequiredAsync()

bartve66 avatar Feb 21 '21 10:02 bartve66

if it helps some one: i'm reinstalled addon add this to configuration of addon and it works

settings: mqttserver: ip adress of your mqtt server mqttusername: your mqtt username mqttpassword: your mqtt password

demonaxxx avatar Feb 28 '21 10:02 demonaxxx

I was not able to save any configuration. After "save" it just disappears on refresh. Uninstall and again install the addon seems to fix the issue. Here is my example configuration after reinstalling the addon:

settings:
  mqttserver: addon_core_mosquitto
  mqttusername: 'username'
  mqttpassword: 'password'

gkrystev avatar Feb 28 '21 13:02 gkrystev

That did the trick! Thanx!

bartve66 avatar Feb 28 '21 15:02 bartve66

Did not work for me :(

utsnik avatar Apr 06 '21 17:04 utsnik

Reinstalling gave me this.

Removing the mqttport line and adding my username/password fixed it. It all loads again and my devices are now shown.

settings:
  mqttserver: addon_core_mosquitto
  mqttport: ''
  mqttusername: ''
  mqttpassword: ''
  mqttsecure: false
  basetopic: zigbee2mqtt
  homeassistantdiscoverybasetopic: homeassistant
  lowbatterythreshold: 30
  allowjointimeout: 20
  autosetlastseen: false
  devicespollingschedule: '*/12 * * * *'
  networkscanschedule: 0 */3 * * *

OmgImAlexis avatar May 28 '21 10:05 OmgImAlexis