0

I'm following Azure IoT Example(https://learn.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-java ) to send data from device to IoTHUb but getting below error :

  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.io.IOException: Could not open the connection
        at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:164)
        at com.microsoft.azure.sdk.iot.device.InternalClient.open(InternalClient.java:130)
        at com.microsoft.azure.sdk.iot.device.DeviceClient.open(DeviceClient.java:317)
        at com.microsoft.docs.iothub.samples.SimulatedDevice.main(SimulatedDevice.java:157)
Caused by: com.microsoft.azure.sdk.iot.device.exceptions.ProtocolException: Unable to establish MQTT connection
        at com.microsoft.azure.sdk.iot.device.transport.mqtt.exceptions.PahoExceptionTranslator.convertToMqttException(PahoExceptionTranslator.java:40)
        at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connect(Mqtt.java:125)
        at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttMessaging.start(MqttMessaging.java:56)
        at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection.open(MqttIotHubConnection.java:180)
        at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.openConnection(IotHubTransport.java:653)
        at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.open(IotHubTransport.java:280)
        at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:160)
        ... 3 more
Caused by: MqttException (0) - java.net.UnknownHostException: XXXIOTHUB.azure-devices.net
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:715)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.net.UnknownHostException: XXXIOTHUB.azure-devices.net
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:80)
        at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:103)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:701)
        ... 7 more

I ping the XXXIOTHUB.azure-devices.net and it's not reachable from my local machine.Do I need to configure any Queue or how could I make this available for my device

Mrityunjay
  • 154
  • 2
  • 9
  • Can you share more details on your hardware setup and be more specific on what you mean by "not reachable"? For example, can you resolve host names for other machines, ex. azure.com? Does XXXIOTHUB.azure-devices.net resolve to an IP address? BTW IoT Hub is not meant to answer to a ping so you shouldn't be alarmed by that alone... – kartben Jan 23 '20 at 15:35
  • I'm using sample code shared at https://github.com/Azure-Samples/azure-iot-samples-java/archive/master.zip and configured IoTHub and create device with symmetric key .The DNS is resolving to an IP but it's eve not reachable – Mrityunjay Jan 23 '20 at 16:00
  • Are you behind a proxy by any chance? Also, you did not answer on whether you can reach other hosts -- in general, it would be great if you could share more error messages etc. – kartben Jan 23 '20 at 17:22
  • I'm not behind any proxy..And azure portal host is reachable – Mrityunjay Jan 23 '20 at 17:49
  • This is confusing. FWIW, your Java stack trace indicates that XXXIOTHUB.azure-devices.net doesn't resolve to an IP address (java.net.UnknownHostException)... What happens when you try from another machine? – kartben Jan 23 '20 at 17:53
  • From another machine it's working .. – Mrityunjay Jan 24 '20 at 09:57

0 Answers0