{"action":"created","issue":{"url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/1925","repository_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota","labels_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/1925/labels{/name}","comments_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/1925/comments","events_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/1925/events","html_url":"https://github.com/arendst/Sonoff-Tasmota/issues/1925","id":297581561,"node_id":"MDU6SXNzdWUyOTc1ODE1NjE=","number":1925,"title":"Connecting to MQTT by a hostname","user":{"login":"mpapierski","id":327556,"node_id":"MDQ6VXNlcjMyNzU1Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/327556?v=4","gravatar_id":"","url":"https://api.github.com/users/mpapierski","html_url":"https://github.com/mpapierski","followers_url":"https://api.github.com/users/mpapierski/followers","following_url":"https://api.github.com/users/mpapierski/following{/other_user}","gists_url":"https://api.github.com/users/mpapierski/gists{/gist_id}","starred_url":"https://api.github.com/users/mpapierski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpapierski/subscriptions","organizations_url":"https://api.github.com/users/mpapierski/orgs","repos_url":"https://api.github.com/users/mpapierski/repos","events_url":"https://api.github.com/users/mpapierski/events{/privacy}","received_events_url":"https://api.github.com/users/mpapierski/received_events","type":"User","site_admin":false},"labels":[{"id":911035386,"node_id":"MDU6TGFiZWw5MTEwMzUzODY=","url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/labels/stale","name":"stale","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2018-02-15T20:13:41Z","updated_at":"2018-12-05T12:44:53Z","closed_at":"2018-06-21T05:24:06Z","author_association":"NONE","body":"Hi!\r\n\r\nI'm running MQTT server on my Raspberry PI on local network. Unfortunately in my home network DHCP leases on wifi are quite short. So often every few days the leases are expiring and IP address of my RPi is changed.\r\n\r\nTo solve this problem I configured my raspberry pi to have a hostname \"raspberrypi.local\" which is perfectly fine if I'm trying to reach it through other computers in the network. I tried to set \"raspberrypi.local\" as MQTT host in my Sonoff devices, but unfortunately Sonoff Tasmota is not able to resolve this hostname and therefore its unable to connect to it. The only workaround I found is to advertise MQTT server on local network through Avahi and reset MqttHost on all devices:\r\n\r\n```sh\r\nfor device sonoff{1..10}; do curl http://$device.local/cm?cmnd=MqttHost%200; done\r\n```\r\n\r\nThis makes Sonoff a lookup in Avahi to find mqtt service in local network. And it works. Until there is another IP address change on RPi. Then Sonoff Tasmota doesn't do Avahi lookup again because IP address is cached.\r\n\r\nIdeally, though, I'd like my devices to connect by a hostname instead of MQTT host, but for some reason it doesn't work. \r\n\r\nLogs from the device itself:\r\n\r\n```\r\n21:09:15 MQT: Attempting connection...\r\n21:09:21 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:09:32 MQT: Attempting connection...\r\n21:09:38 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:09:49 MQT: Attempting connection...\r\n21:09:55 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:10:06 MQT: Attempting connection...\r\n21:10:12 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:10:23 MQT: Attempting connection...\r\n21:10:29 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:10:40 MQT: Attempting connection...\r\n21:10:46 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:10:57 MQT: Attempting connection...\r\n21:11:03 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:11:14 MQT: Attempting connection...\r\n21:11:20 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:11:31 MQT: Attempting connection...\r\n21:11:38 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n21:11:48 MQT: Attempting connection...\r\n21:11:55 MQT: Connect failed to raspberrypi.local:1883, rc -2. Retry in 10 sec\r\n```\r\n\r\nI know a little about programming so I'd love to send a pull request if anybody has time to point where should I look to do a fix.\r\n\r\nBTW I'm using Sonoff-Tasmota 5.11.1 downloaded from the Releases page.\r\n\r\nEDIT:\r\nI did a little investigation so I'd like to ask if `sonoff.bin` is compiled with `MQTT_HOST_DISCOVERY`? It looks like it has something to do with mDNS requests.\r\n\r\nEDIT2:\r\n\r\nI updated to 5.12.0 and the problem remains."},"comment":{"url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/comments/444472600","html_url":"https://github.com/arendst/Sonoff-Tasmota/issues/1925#issuecomment-444472600","issue_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/1925","id":444472600,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDQ3MjYwMA==","user":{"login":"ascillato","id":35405447,"node_id":"MDQ6VXNlcjM1NDA1NDQ3","avatar_url":"https://avatars1.githubusercontent.com/u/35405447?v=4","gravatar_id":"","url":"https://api.github.com/users/ascillato","html_url":"https://github.com/ascillato","followers_url":"https://api.github.com/users/ascillato/followers","following_url":"https://api.github.com/users/ascillato/following{/other_user}","gists_url":"https://api.github.com/users/ascillato/gists{/gist_id}","starred_url":"https://api.github.com/users/ascillato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ascillato/subscriptions","organizations_url":"https://api.github.com/users/ascillato/orgs","repos_url":"https://api.github.com/users/ascillato/repos","events_url":"https://api.github.com/users/ascillato/events{/privacy}","received_events_url":"https://api.github.com/users/ascillato/received_events","type":"User","site_admin":false},"created_at":"2018-12-05T12:44:53Z","updated_at":"2018-12-05T12:44:53Z","author_association":"CONTRIBUTOR","body":"already implemented and working. please see wiki at rules or the full explanation at: https://github.com/arendst/Sonoff-Tasmota/issues/4527"}}
{"actor":{"display_login":"ascillato"}}