Skip to content

connect by hostname - not working #1069

@quax1

Description

@quax1

Please ignore - works well in another WLAN - so it is a problem of my home WLAN and not of the library

Hello,
I want to connect to a mosquitto MQTT Server on my local network with the hostname instead of the ip adress. But connect fails, however, connect with IP is OK and connect with mosquitto_pub or MQTT Explorer using hostname works fine.

Seems to me that the hostname only is not enough...

Details
I used the current Basic ESP8266 MQTT example: mqtt_esp8266.ino

works OK with servername on internet:
const char* mqtt_server = "broker.mqtt-dashboard.com";

works OK with IP of my local server:
const char* mqtt_server = "192.168.2.33";

Now trying to connect with hostname - fail
const char* mqtt_server = "IMW1";

Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

But connection with MQTT Explorer or with mosquitto publisher is OK:
just found out mosquitto_pub with hostname takes ca. 2s until it is transmitted, with IP it is immediate. So it is a problem in my network ?

mosquitto_pub -d -h "IMW1" -t testTopic -m "Hello world!"
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending PUBLISH (d0, q0, r0, m1, 'testTopic', ... (12 bytes))
Client (null) sending DISCONNECT

Probably it is stupid - but I do have no idea why it is not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions