eclipse-paho / eclipse-paho/paho.mqtt.java

java.lang.IllegalArgumentException: no NetworkModule installed for scheme "wss" of URI

Open
#720 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

Hi, I upgraded DeviceClient to 1.18.0 with all its dependencies and now I am getting following IllegalArgumentException while creating DeviceClient, if I keep the DeviceClient version 1.16.0, I don't see following exception:

**java.lang.IllegalArgumentException: no NetworkModule installed for scheme "wss" of URI "wss://dev-lram-iot.azure-devices.net/$iothub/websocket?iothub-no-client-cert=true"java.lang.IllegalArgumentException: no NetworkModule installed for scheme "wss" of URI "wss://dev-lram-iot.azure-devices.net/$iothub/websocket?iothub-no-client-cert=true"
at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:72) at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:72)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:454) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:454)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:320) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:320)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:315) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:315)
at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttConnection.(MqttConnection.java:65) at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttConnection.(MqttConnection.java:65)
at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection.open(MqttIotHubConnection.java:171) at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection.open(MqttIotHubConnection.java:171)
at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.openConnection(IotHubTransport.java:707) at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.openConnection(IotHubTransport.java:707)
at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.open(IotHubTransport.java:273) at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.open(IotHubTransport.java:273)
at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:158) at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:158)
at com.microsoft.azure.sdk.iot.device.InternalClient.open(InternalClient.java:123) at com.microsoft.azure.sdk.iot.device.InternalClient.open(InternalClient.java:123)
at com.microsoft.azure.sdk.iot.device.DeviceClient.open(DeviceClient.java:316) at com.microsoft.azure.sdk.iot.device.DeviceClient.open(DeviceClient.java:316)**

Any help will be greatly appreciated, thanks
Here is my code:

`public class IoT-Application
{
private static DeviceClient client = null;
private static DeviceMethodStatusCallBack deviceMethodStatusCallBack = null;

public IoT-Application()
{
deviceMethodStatusCallBack = new DeviceMethodStatusCallBack();
}

/**
* Send message to iot hub
*/
private static void sendMessage(JSONObject content, String type)
{
content.put("iotDeviceId", client.getConfig().getDeviceId());
Message message = new Message(content.toString());
message.setProperty("type", type);
client.sendEventAsync(message, deviceMethodStatusCallBack, null);
}

/**
* Hub event callback that just echos status.
*/
protected static class DeviceMethodStatusCallBack implements IotHubEventCallback
{
@Override
public void execute(IotHubStatusCode status, Object context)
{
Activator.getLog().debug(" IotHubEventCallback execute method called with status::" +
status.name());
}
}

/**
* Message callback that just echos the message received.
*/
private static MessageCallback messageCallback = (message, context) -> {
Activator.getLog().debug(" MessageCallback received message: " +
new String(message.getBytes(), StandardCharsets.UTF_8));
return IotHubMessageResult.COMPLETE;
};

/**
* Direct method callback handler.
*/
private static class DirectMethodCallback implements DeviceMethodCallback
{
/**
* Executes the specified direct method.
*
* @param methodName The name of the method.
*
* @param methodData The method body (JSON).
*
* @param context The context in which the method was called.
*
* @return The status of the method result.
*/
@Override
public DeviceMethodData call(String methodName,
Object methodData, Object context)
{
Activator.getLog().debug(" Incoming method: " + methodName);
return new DeviceMethodData(200, "StringData");
}
}

@Override
public void init()
{

Thread t = new Thread(() -> {
try
{

client = new DeviceClient("",
IotHubClientProtocol.MQTT_WS);
client.open();
client.setMessageCallback(messageCallback, new HashMap<>());
client.subscribeToDeviceMethod(new DirectMethodCallback(), null,
deviceMethodStatusCallBack, null);
Long sasTime = new Long(300);
client.setOption("SetSASTokenExpiryTime", sasTime);
}
catch (URISyntaxException syntaxException)
{
Activator.getLog().info("Invalid URI syntax");
}
catch (Throwable tr)
{
tr.printStackTrace();
}
});
t.setName("IoT-device-thread");
t.start();
}
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.