添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello,

I have developed a Spring Boot project using the spring-integration-mqtt library which under the hood uses org.eclipse.paho.client.mqttv3 . It works fine getting connected to a local MQTT that I have with the following configuration:

mqtt:
  options:
    automatic-reconnect: true
    clean-session: true
    connection-timeout: 10
    user-name: ****
    password: ****
    keep-alive-interval: 100    
  hostname: tcp://10.142.90.116:1883

Also I can connect to Azure IOT Hub using my MQTT explorer client:

But if I change my config file to:

mqtt:
  options:
    (...)   
  hostname: tcp://OffimanIoT.azure-devices.net/device/?api-version=2021-04-12:1883

It throws error java.lang.IllegalArgumentException: URI path must be empty "tcp://OffimanIoT.azure-devices.net/device/?api-version=2021-04-12:1883"

If I use:

mqtt:
  options:
    (...)   
  hostname: tcp://OffimanIoT.azure-devices.net

It throws Connection timeout.

And if I use:

mqtt:
  options:
    (...)   
  hostname: mqtt://OffimanIoT.azure-devices.net/device/?api-version=2021-04-12:1883

It throws java.lang.IllegalArgumentException: no NetworkModule installed for scheme "mqtt" of URI "mqtt://OffimanIoT.azure-devices.net/device/?api-version=2021-04-12:1883".

Does anyone know how to fix this? Thanks in advance for your help.

Best regards,

Jaime.

Hi @Jaime Greetings! I am following up to see if you got a chance to review the below response. Please let us know if you have any additional questions or need further assistance.

If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

Hello @Jaime,

you can see how the IoT Hub supports MQTT without using any of the Azure IoT Device SDKs here.

The example is written in C# but you get a feeling on how the specific topics are working.

There, you see you need to provide the SAS token for a device.

Is your device named 'device' as seen in:

hostname: tcp://OffimanIoT.azure-devices.net/device/?api-version=2021-04-12:1883

I'm not sure if the 'tcp://' or 'mqtt://' are working.

Regarding the port, please check if you use 8883 as documented.

If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.