The PC with Windows 10
The B4J version 9.00 and 9.10
I have a program that connects to MQTT broker. It works fine in Debug and Release mode.
But after building Standalone package the program fails with followings:
connector._connectto (java line: -1)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://broker.hivemq.com:1883"
at b4j/org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(Unknown Source)
at b4j/org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(Unknown Source)
at b4j/org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(Unknown Source)
at b4j/org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(Unknown Source)
at b4j/org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(Unknown Source)
at b4j/anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(Unknown Source)
at b4j/b4j.example.connector._connectto(Unknown Source)
at b4j/b4j.example.main._btnconnect_click(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
My guess is that you maybe trying to connect with web sockets protocol instead of the tcp protocol, thus failing as your url should be ws:, or it could be also that your broker is expecting ssl: instead of tcp:
Why this happens on standalone package, is hard to know without looking at the code
My guess is that you maybe trying to connect with web sockets protocol instead of the tcp protocol, thus failing as your url should be ws:, or it could be also that your broker is expecting ssl: instead of tcp:
Why this happens on standalone package, is hard to know without looking at the code
No. I connect to tcp://broker.hivemq.com:1883 and everything works in Debug and Release mode.
I think something wrong in Build and standalone package or B4J last versions.
Implementation of MQTT client based on the Paho open source project: http://www.eclipse.org/paho/ See this tutorial for more information: https://www.b4x.com/android/forum/threads/iot-mqtt-protocol.59471/ jMQTT.zip holds the older version, which is compatible with B4A. B4J_Only_jMQTT.zip -...
The problem has been solved by adding the #Packager property. Thank you very much.
It was strange that in previous versions the standalone program worked without adding the property.