Android Question Mqtt chat with autodiscovery and hotspot problem

postasat

Active Member
Licensed User
Hello,
I have a problem using mqtt chat with autodiscovery and hotspot.
I need to use mqtt chat in a place without wifi.
I created an Hotspot on a tablet that I use as "server/host" but the clients can't connect.
If I turn on hotspot on "server/host" (with or without mobile data on) I have a connection error (success=false) in clients.

Thank you.
 

postasat

Active Member
Licensed User
Hi Erel, Perfect.

I modified the code in PacketArrived and now all is good.

B4X:
Private Sub AutoDiscover_PacketArrived (Packet As UDPPacket)
    
    Try
        Dim bc As ByteConverter
        Dim data(Packet.Length) As Byte
        bc.ArrayCopy(Packet.Data, Packet.Offset, data, 0, Packet.Length)
        Dim ds As String = serializator.ConvertBytesToObject(data)
        If ds <> DiscoveredServer Then
            DiscoveredServer = ds
            If DiscoveredServer = "127.0.0.1" Then DiscoveredServer="192.168.43.1"
            Log("Discovered server: " & DiscoveredServer)
            CallSub(Main, "UpdateState")
        End If
    Catch
        Log(LastException)
    End Try
    
End Sub

Thank you!
 
Upvote 0
Top