Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » connectWithResult(options) infinite wait(Thread calling the method stay in WAITING state even after timeout)
connectWithResult(options) infinite wait [message #1739004] Tue, 26 July 2016 17:24 Go to next message
Alexandre MARCHAL is currently offline Alexandre MARCHALFriend
Messages: 2
Registered: July 2016
Junior Member
Hello,

I am using an HiveMQ 3.1.3 server with Paho mqttv3 library 1.1.0

In my thread I set the connection timeout doing :
connectionOptions.setConnectionTimeout(60);


The thread tries to initiate connection, I saw MQTT Connect packet arriving in tcpdump on server side but :
- connectWithResult does not seem to accept the connection
- after 60s (timeout set) nothing happens

Here is an extract of thread dump made after several minutes :

java.lang.Thread.State: WAITING
	at java.lang.Object.wait(Native Method)
	- waiting on <e35afed> (a java.lang.Object)
	at java.lang.Object.wait(Unknown Source)
	at org.eclipse.paho.client.mqttv3.internal.Token.waitForResponse(Token.java:141)
	at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:108)
	at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)
	at org.eclipse.paho.client.mqttv3.MqttClient.connectWithResult(MqttClient.java:248)
	at araxxe.utils.eventsHandling.ArxMQTTConnector.connect(ArxMQTTConnector.java:176)


The thread is still stuck in WAITING state, nothing happens anymore.

Could you help me ? How can I go deeper in my diagnostic ?

Thanks,
Alexandre
Re: connectWithResult(options) infinite wait [message #1739418 is a reply to message #1739004] Mon, 01 August 2016 08:08 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
It sounds like you haven't set timeToWait, timeToWait is different from the connection timeout and is an overriding part of the Paho Blocking client. By default timeToWait is -1 which means that it will wait forever, you will want to either switch to the MqttAsyncClient, or use setTimeToWait so that the connect returns as a failure after your specified time. https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/MqttClient.java#L420
Re: connectWithResult(options) infinite wait [message #1739807 is a reply to message #1739004] Thu, 04 August 2016 15:45 Go to previous message
Alexandre MARCHAL is currently offline Alexandre MARCHALFriend
Messages: 2
Registered: July 2016
Junior Member
Thank you for your reply.

As my issue was directly on connect, I was too focused on the connection options forgetting the mqttClient side. It is ok now with this parameter.

BTW : The main issue on connection was on HiveMQ broker side. As they were an Exception on the broker, it sends an ACK to the connection packet but never the Connected / KO paquet in response.
Previous Topic:MQTTClient PublishMessage Bug
Next Topic:Connecting to distributed broker
Goto Forum:
  


Current Time: Tue Apr 23 12:01:15 GMT 2024

Powered by FUDForum. Page generated in 0.03661 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top