Android Tutorial [B4X] MQTT Chat Room

Status
Not open for further replies.
It's time to learn how to use MQTT: https://www.b4x.com/android/forum/threads/59471/#content
It is simple and powerful. In most cases MQTT is the best solution for low level networks. Low level network means a network solution that is traditionally based on ServerSocket + Socket + AsyncStreams.

In this example we implement a chat room with one or more users. The MQTT broker is embedded in the Android app (jMqttBroker library). The clients are Android, iOS or desktop apps. Any number of users can join.


upload_2015-12-21_14-42-4.png
upload_2015-12-21_14-43-50.png


SS-2015-12-21_14.40.07.png


When you start the Android app you can choose whether it will be the server. The other clients will connect to the server.

The messages are serialized with B4XSerializator (RandomAccessFile library). B4XSerializator is very useful for cross platform communication.

Users can join and leave the chat room. The list of users will be updated automatically.
Note the usage of the LastWill feature. When a client is disconnected unexpectedly (and only if it is unexpectedly) the LastWill message will be sent. This allows us to remove the client from the list.

The UI state is managed by StateManager (in B4A and B4i).
It is a simple and flexible UI implemented with anchors. Note that it properly handles the soft keyboard changes.

jMQTT library: https://www.b4x.com/android/forum/threads/59472/#content
jMqttBroker: https://www.b4x.com/android/forum/threads/mqttbroker.61548

Extension to this example with auto discovery: https://www.b4x.com/android/forum/posts/480542/
 

Attachments

  • Chat_B4i.zip
    6.1 KB · Views: 2,254
  • Chat_B4J.zip
    3.8 KB · Views: 3,573
  • Chat_B4A.zip
    11.3 KB · Views: 2,786
Last edited:

archeus

Member
Licensed User
Longtime User
I was testing this code with CloudMQTT.

No problem to make it work, change the code to use it just like a client.

But if I use let's say MqttFX (MQTT client in Java) or MyMQTT and connect it to my CloudMQTT account (I use another credential than the one use in my Android App).

Each time MqttFX send message, My Android App crash. And all message sent by my app are unreadeable by MyMQTT or MqttFX.
If I deploy my app on 2 different android device, they are perfectly able to communicate, no crash. MyMQTT and MqttFX are perfectly able to communicate each other.

Problem seems to be here (in Starter)

B4X:
Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
    Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)

I saw on some MQTT docs that Payload are Byte.

I try to log Payload to see the data but crash (i'm a B4a newbie btw).

Is this code use a different format than the one usually use by other software to send data ? How can I convert text coming from traditional mqtt software to be readable by the App ?

Thanks for help
 

MolsonB

Member
Licensed User
Longtime User
In the B4A program, the Sub "Disconnect" in the Starter service module is missing the publish disconnect command.

B4X:
Public Sub Disconnect
    If connected Then
        connected = False
        client.Publish2("all/disconnect", serializator.ConvertObjectToBytes(currentName), 0, False)
        client.Close
    End If
End Sub
 

Gandalf

Member
Licensed User
Longtime User
In the B4A program, the Sub "Disconnect" in the Starter service module is missing the publish disconnect command.

You are correct. LastWill message will only be published in case of unexpected disconnect. If you do disconnect with Client.Close, you need to publish disconnect message manually before closing client. Making LastWill and Disconnect messages different allows differentiating unexpected disconnects from intended and properly indicating them on server side.
 

ValhallSW

Member
Licensed User
Longtime User
I have tried this before: To make the PC/B4J as server. I love the example in the first post, but I have huge problem making B4J as server. I have tried what Erel told me, but when I connect to 127.0.0.1 it crashed/stopped. I feel like I've tried a lot of configurations. With no luck.

So:

Are there anyone that can help me to get the PC/B4J to work as the server in this example? PLEASE
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi,
MQTT Chat could be implemented also within the same network where I have implemented CloudKVS server?
 

cxdzbl

Active Member
Licensed User
It's time to learn how to use MQTT: https://www.b4x.com/android/forum/threads/59471/#content
It is simple and powerful. In most cases MQTT is the best solution for low level networks. Low level network means a network solution that is traditionally based on ServerSocket + Socket + AsyncStreams.

In this example we implement a chat room with one or more users. The MQTT broker is embedded in the Android app (jMqttBroker library). The clients are Android, iOS or desktop apps. Any number of users can join.


View attachment 39859 View attachment 39863

SS-2015-12-21_14.40.07.png


When you start the Android app you can choose whether it will be the server. The other clients will connect to the server.

The messages are serialized with B4XSerializator (RandomAccessFile library). B4XSerializator is very useful for cross platform communication.

Users can join and leave the chat room. The list of users will be updated automatically.
Note the usage of the LastWill feature. When a client is disconnected unexpectedly (and only if it is unexpectedly) the LastWill message will be sent. This allows us to remove the client from the list.

The UI state is managed by StateManager (in B4A and B4i).
It is a simple and flexible UI implemented with anchors. Note that it properly handles the soft keyboard changes.

jMQTT library: https://www.b4x.com/android/forum/threads/59472/#content
jMqttBroker: https://www.b4x.com/android/forum/threads/mqttbroker.61548

Extension to this example with auto discovery: https://www.b4x.com/android/forum/posts/480542/
Subscription: client.Subscribe ("all/#", 2)
Send: client.Publish2 ("all/ycwx", serializator.ConvertObjectToBytes (), 2, true)
When the client is online, the messages can receive messages. After shutdown, the messages sent by other clients can not be received. (I don't use the Mqttbroker library.) what's wrong with me?
 

cxdzbl

Active Member
Licensed User
If you dont use the MqttBroker library then this thread is probably the wrong place for your question as this thread is about MqTT chatroom
I found it wasn't MqttBroker's problem:
1, each client clinetID must be fixed and unique.
2, to CleanSession=False. Ensure persistence
3, Subscribe ("all/#", 0) cannot repeat the subscription, or an unknown error will occur.
Thank you, donmanfred. I don't know how to make sure the client has subscribed yet.
 

CharliBlanchard

New Member
It's time to learn how to use MQTT: https://www.b4x.com/android/forum/threads/59471/#content
It is simple and powerful. In most cases MQTT is the best solution for low level networks. Low level network means a network solution that is traditionally based on ServerSocket + Socket + AsyncStreams.

In this example we implement adult chat rooms with one or more users. The MQTT broker is embedded in the Android app (jMqttBroker library). The clients are Android, iOS or desktop apps. Any number of users can join.


View attachment 39859 View attachment 39863

SS-2015-12-21_14.40.07.png


When you start the Android app you can choose whether it will be the server. The other clients will connect to the server.

The messages are serialized with B4XSerializator (RandomAccessFile library). B4XSerializator is very useful for cross platform communication.

Users can join and leave the chat room. The list of users will be updated automatically.
Note the usage of the LastWill feature. When a client is disconnected unexpectedly (and only if it is unexpectedly) the LastWill message will be sent. This allows us to remove the client from the list.

The UI state is managed by StateManager (in B4A and B4i).
It is a simple and flexible UI implemented with anchors. Note that it properly handles the soft keyboard changes.

jMQTT library: https://www.b4x.com/android/forum/threads/59472/#content
jMqttBroker: https://www.b4x.com/android/forum/threads/mqttbroker.61548

Extension to this example with auto discovery: https://www.b4x.com/android/forum/posts/480542/
It possible to chat with individual users.
 

ivanomonti

Expert
Licensed User
Longtime User
I have great difficulty using these examples, b4j seems to work but instead android crashes me with a mountain of errors unable to do anything.

host: 127.0.0.1

B4J:
Waiting for debugger to connect...
Program started.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.channel.nio.NioEventLoop (file:/C:/B4JavaFolder/B4Java-library/moqueutte.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of io.netty.channel.nio.NioEventLoop
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Connected: true
all/connect: MIASmart


Android:
Logger connesso a:  samsung SM-T530
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Resume **
Error occurred on line: 40 (Starter)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://127.0.0.1:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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 java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.example.starter._connectto(starter.java:143)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew3(Debug.java:288)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug3(Common.java:1092)
    at b4a.example.main._btnconnect_click(main.java:470)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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 java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
Error occurred on line: 40 (Starter)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://m11.cloudmqtt.com:99999"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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 java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.example.starter._connectto(starter.java:143)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew3(Debug.java:288)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug3(Common.java:1092)
    at b4a.example.main._btnconnect_click(main.java:470)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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 java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
Error occurred on line: 40 (Starter)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug3(Common.java:1092)
    at b4a.example.main._btnconnect_click(main.java:470)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew3(Debug.java:288)
    ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 26 more
Caused by: java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://127.0.0.1:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:179)
    ... 29 more

I need help, thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Which version of jMQTT are you using with B4A?

 

ivanomonti

Expert
Licensed User
Longtime User
I'm trying to evaluate this mini MTTQ chat but it gives me an error and I don't know where to go

B4X:
Public Sub ConnectTo(Host As String, Name As String)
    currentName = Name
    isServer = Host = "127.0.0.1"
    If isServer Then
        If brokerStarted = False Then
            broker.Start
            brokerStarted = True
        End If
        users.Clear
        Host = "127.0.0.1"
    End If
    If connected Then client.Close
    client.Initialize("client", $"tcp://${Host}:${port}"$, "android" & Rnd(1, 10000000)) ' error'
    Dim mo As MqttConnectOptions
    mo.Initialize("", "")
    'this message will be sent if the client is disconnected unexpectedly.
    mo.SetLastWill("all/disconnect", serializator.ConvertObjectToBytes(currentName), 0, False)
    client.Connect2(mo)
End Sub

B4X:
Logger connesso a:  samsung SM-T530
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
starter_connectto (java line: 252)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://127.0.0.1:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:252)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example.main._btnconnect_click(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
starter_connectto (java line: 252)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://127.0.0.1:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:252)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example.main._btnconnect_click(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
starter_connectto (java line: 252)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://192.168.1.41:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:252)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example.main._btnconnect_click(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
starter_connectto (java line: 252)
java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://151.66.30.22:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:252)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
    at b4a.example.main._btnconnect_click(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
Error occurred on line: 40 (Starter)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug3(Common.java:1092)
    at b4a.example.main._btnconnect_click(main.java:470)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5214)
    at android.view.View$PerformClick.run(View.java:20978)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew3(Debug.java:288)
    ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 26 more
Caused by: java.lang.IllegalArgumentException: no NetworkModule installed for scheme "tcp" of URI "tcp://192.168.1.41:51042"
    at org.eclipse.paho.client.mqttv3.internal.NetworkModuleService.validateURI(NetworkModuleService.java:74)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:574)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:438)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:322)
    at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
    at anywheresoftware.b4j.objects.MqttAsyncClientWrapper.Initialize(MqttAsyncClientWrapper.java:70)
    at b4a.example.starter._connectto(starter.java:179)
    ... 29 more
 
Status
Not open for further replies.
Top