emqx / mqtt-jmeter

MQTT JMeter Plugin

Home Page:https://www.emqx.com/en

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TimeoutException when connecting to Azure Iothub

AzureUser123 opened this issue · comments

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.

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

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

Can you telnet to port of Azure MQTT server?

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?

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

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

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.. :)

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

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

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

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

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

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

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

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).

@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

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

@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

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.

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!! 👍 👍 👍

@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