fusesource / mqtt-client

A Java MQTT Client
http://mqtt-client.fusesource.org/
Apache License 2.0
1.27k stars 369 forks source link

Cannot connect when client hostname changed #119

Open jwh331 opened 4 years ago

jwh331 commented 4 years ago

Hello, I need some help with mqtt connection.

I place an mqtt client(runnable jar) on host "A". and set host "B" as apache activeMQ server.

If I send some test data A to B, It works fine. But when I modify hostname A, mqtt client cannnot connect to host B.

ERROR LOG:

Exception in thread "main" java.util.concurrent.TimeoutException at org.fusesource.mqtt.client.Promise.await(Promise.java:83) at app.Main.main(Main.java:24)

Client codes are below:

String data = "...testdata...";
MQTT mqtt = new MQTT();
mqtt.setHost("host-B-Domain.com", 1883);
mqtt.setUserName("testUser");
mqtt.setPassword("testPwd");
mqtt.setWillRetain(false);

FutureConnection connection = mqtt.futureConnection();
connection.connect().await(5, TimeUnit.SECONDS);    **#connectionTimeout occurs**
connection.publish(
    new UTF8Buffer("testBufferData"), new AsciiBuffer(data), QoS.EXACTLY_ONCE, false);
connection.disconnect().await();

firewall config is OK and tested with telnet command.

I've also checked with tcpdump. If hostname changed, mqtt does not send any packets to host B. And activeMQ doesn't have any restrictions about hostname.

Both hosts are running with CentOS 7 x64. And using java-1.8.0-openjdk-headless-1.8.0.91-1.b14.el7_2.x86_64.

How can I solve this issue?

any comments are appreciated. Thanks!