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

unable to connect to mqtt server #367

Open
bluesailor45 opened this issue Feb 13, 2021 · 10 comments
Open

unable to connect to mqtt server #367

bluesailor45 opened this issue Feb 13, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@bluesailor45
Copy link

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 bluesailor45 added the bug Something isn't working label Feb 13, 2021
@empatel96
Copy link

empatel96 commented Feb 13, 2021

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()

@jimmyeao
Copy link

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

@davisdmg
Copy link

Same! Installed from HACS

@bartve66
Copy link

bartve66 commented Feb 21, 2021

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()

@demonaxxx
Copy link

demonaxxx commented Feb 28, 2021

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

@gkrystev
Copy link

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'

@bartve66
Copy link

That did the trick! Thanx!

@utsnik
Copy link

utsnik commented Apr 6, 2021

Did not work for me :(

@OmgImAlexis
Copy link

OmgImAlexis commented May 28, 2021

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 * * *

@federicotravaini
Copy link

I have the same error but can't understand how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants