B4J Question Program fails when connecting to MQTT server in standalone mode

EvgenyB4A

Active Member
Licensed User
Longtime User
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)

What is the problem?
 

bdunkleysmith

Active Member
Licensed User
Longtime User
Perhaps as per this post https://www.b4x.com/android/forum/threads/jmqtt-official-mqtt-client.59472/ try if not already done:

If building a standalone package then add this to the main module:

B4X:
#PackagerProperty: AdditionalModuleInfoString = provides org.eclipse.paho.client.mqttv3.spi.NetworkModuleFactory with org.eclipse.paho.client.mqttv3.internal.TCPNetworkModuleFactory, org.eclipse.paho.client.mqttv3.internal.SSLNetworkModuleFactory,  org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketNetworkModuleFactory, org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModuleFactory;
 
Upvote 0
Top