B4J Question Program fails when try to connect to MQTT broker in standalone package

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?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
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
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
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.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think something wrong in Build and standalone package or B4J last versions.
No. No. No.
Have you followed the instructions?

 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
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.
 
Upvote 0
Top