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

TimeoutException when connecting to Azure Iothub #21

Closed
AzureUser123 opened this issue Sep 18, 2017 · 22 comments
Closed

TimeoutException when connecting to Azure Iothub #21

AzureUser123 opened this issue Sep 18, 2017 · 22 comments

Comments

@AzureUser123
Copy link

AzureUser123 commented Sep 18, 2017

Hi,
I've been trying to send a payload data to a device in azure iot hub through this mqtt plugin in jmeter. But it doesn't connect to the hub and there's an exception throwing as below.

ERROR - net.xmeter.samplers.PubSampler:  java.util.concurrent.TimeoutException
	at org.fusesource.mqtt.client.Promise.await(Promise.java:83)
	at net.xmeter.samplers.PubSampler.sample(PubSampler.java:141)
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
	at java.lang.Thread.run(Thread.java:748)

Is there any more configurations need to be done in addition to clientId, Topic name,Username,Password and Server name or IP?
Thank you in advance.

@jinfahua
Copy link
Member

Please refer to #4. You probably need to specify a correct clientId.

@AzureUser123
Copy link
Author

I have used deviceId as the clientId as mentioned. But still it doesn't connect.

@jinfahua
Copy link
Member

Can you telnet to port of Azure MQTT server?

@AzureUser123
Copy link
Author

AzureUser123 commented Sep 20, 2017

yes.. I think it's because the mqtt connection version. Now I'm trying to use v3.1.1. since it is the version azure iothub uses to connect. where should I change in the sourcecode to use a different mqtt version?

@AzureUser123
Copy link
Author

I have changed PubSampler.java to use v3.1.1 by using mqtt.setVersion("3.1.1");
and it worked.

@jinfahua
Copy link
Member

Cool, what's the default version? If it's a common requirement, we'd better expose the option in the UI.

@AzureUser123
Copy link
Author

Default version is v3.1. But azure uses only v3.1.1 as the mqtt version to connect to the hub. It's better if the user has the option to select the version.. :)

@jinfahua
Copy link
Member

OK, we'll add the feature to future release, thanks for your feedback.

@jinfahua
Copy link
Member

Refer to below screenshot, added another option for MQTT protocol version. I don't have a MQTT server support 3.1.1, could help to try the fix attached in below? Thanks.

2017-09-29 8 35 01

mqtt-xmeter-jar-with-dependencies.jar.zip

@AzureUser123
Copy link
Author

Hi,
yes.. it was working. I have used port 8883 since azure iot hub does not allow port 1883. Thank you for integrating this.. :)

untitledss

@jinfahua
Copy link
Member

Great, thanks for your help. I close the issue, and it will be included in next release.

@saurabh-saviant
Copy link

saurabh-saviant commented Jan 30, 2018

Hi,

I am trying to connect to Azure IoT Hub using JMeter but unable to connect. JMeter shows below error,

“Connection org.fusesource.mqtt.client.FutureConnection@2ae2a5 connected failed.” (Sampler request panel)
“ERROR - net.xmeter.samplers.ConnectionSampler: Could not connect: CONNECTION_REFUSED_NOT_AUTHORIZED org.fusesource.mqtt.client.MQTTException: Could not connect: CONNECTION_REFUSED_NOT_AUTHORIZED ” (Log viewer panel)

I have referred following links but no success,

#21 (downloaded mqtt-xmeter-jar-with-dependencies.jar.zip)
#23

Below is my MQTT Connection Sampler configuration,
Server name: {iothubhostname}
Port Number: 8883
Protocols: SSL (Duel SSL auth. ‘OFF’)
Username: {iothubhostname}/{device_id}/api-version=2016-11-14
Password: SAS Token generated

All the details entered are correct. Kindly guide me through this. Thanks.

Regards,
Saurabh

@jinfahua
Copy link
Member

You did not mention how you specify the clientID, is clientID correct? Thanks.

@saurabh-saviant
Copy link

Thanks for the reply. Sorry, I forgot to mention the clientID.

The clientID is exactly same as the 'Device ID' which is correct. This Device ID is registered in Azure IoT Hub so that I can send the messages to IoT Hub for this device.'Add random client id suffix' is 'Unchecked'
With this same configuration, I am able to send messages to IoT Hub using 'MQTTBox' tool (http://workswithweb.com/mqttbox.html) but unable to do the same with JMeter.
Please see attached the screenshot:
jmeter_mqtt

@jinfahua
Copy link
Member

You are not using the latest version of plugin, please download the latest version of JAR and replace your current. The latest version of plugin should have an option for selecting 'MQTT version', please select 3.1.1 in that drop-down box (which is also mentioned in homepage - https://github.com/emqtt/mqtt-jmeter).

@saurabh-saviant
Copy link

@jinfahua
The screenshot which I shared doesn't show the 'MQTT Version' field because I updated the JAVA version to 'Java version 8 update 161'. My previous version was 'Java 8 update 151' in which I could select the MQTT version to 3.1.1 which is supported by Azure IoT Hub. I think in 'Java version 8 update 161' there is an issue with the latest version of the plugin. Please check.
Now, back to my original problem
It worked with 'Java update 151'. I could connect to IoT Hub and send the message. Thanks a lot!
image

@jinfahua
Copy link
Member

Did you use Open JDK, Sun JDK or IBM JDK of version 8 update 161?

@saurabh-saviant
Copy link

'Sun JDK' which is now 'Java Oracle'
https://java.com/en/download/faq/release_changes.xml

@reubenrajan
Copy link

@saurabh-saviant - i am pretty new to Azure IOT, how do i get the password. I only see primary key and secondary keys in the Device registry in IOT hub. Do you i need to create separate SAS tokens? and if you could share a screenshot of the

@AzureUser123
Copy link
Author

AzureUser123 commented Jan 30, 2019

To create a SAS token you can download Azure device explorer. Download it from here or any other source.
image
Add the IoT Hub Connection String, Hostname -> Click on Update. Then click on Generate SAS. This will create a SAS token. Use this token as the password.

@reubenrajan
Copy link

reubenrajan commented Jan 30, 2019

I found a way of using Azure IOT Tools on VSCode to generate the SAS password. My problem is resolved. in the earlier screenshots that @saurabh-saviant had shared showed '&' before API-Version. It's actually '/'. and it worked!

screen shot 2019-01-31 at 11 20 42 am

Thanks for the help here!! 👍 👍 👍

@ranjanriseup
Copy link

@jinfahua
The screenshot which I shared doesn't show the 'MQTT Version' field because I updated the JAVA version to 'Java version 8 update 161'. My previous version was 'Java 8 update 151' in which I could select the MQTT version to 3.1.1 which is supported by Azure IoT Hub. I think in 'Java version 8 update 161' there is an issue with the latest version of the plugin. Please check.
Now, back to my original problem
It worked with 'Java update 151'. I could connect to IoT Hub and send the message. Thanks a lot!
image

I have tried to get connection with MQTT server but still showing error as "Failed to establish Connection null."
mqtt1
mqtt2
Please let me know what kind of missing content in this request.
As i have hit request from MQTTbox its getting connect.
MQTT
mqttt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants