Android Question [RESOLVED]Mqtt.initialize IllegalArgumentException fails on older Android (6.1)

giggetto71

Active Member
Licensed User
Longtime User
Hi
I have an app that works fine and connects nicely to mqtt with newer Android (8,9,10). I am using mqtt lib 1.01
I have tried to install it in a old 6.1 phone I have and the app crashes upon calling:

B4X:
 mqtt.Initialize("mqtt", BrokerProtocol & "://" & BrokerAddr & ":" & BrokerPort, BrokerClientID)

*** Service (mqttservice) Create ***
Error occurred on line: 362 (MQTTService)
java.lang.IllegalArgumentException: tcp://m21.cloudmqtt.com :10000
at org.eclipse.paho.client.mqttv3.MqttConnectOptions.validateURI(MqttConnectOptions.java:473)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:273)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:167)
at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:51)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at gigiosoft.MQTTAlert.mqttservice._connect2mqttbroker(mqttservice.java:359)
at gigiosoft.MQTTAlert.mqttservice._service_create(mqttservice.java:2473)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at gigiosoft.MQTTAlert.mqttservice.onCreate(mqttservice.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3873)
at android.app.ActivityThread.access$2100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1909)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)


I have checked in debug and the arguments are actually fine just like when I run on newer Android.
Does anyone know why the mqtt initialize method fails this way?
thanks!
 

giggetto71

Active Member
Licensed User
Longtime User
sorry...found the issue..
I had the broker address which had a space at the end of the name..I will trim it in the UI...my mistake
 
Upvote 0
Top