admin管理员组

文章数量:1401849

I'll start by saying, that although I've programmed in C for embedded devices for a while, i'm very new to Android development.

The issue I'm having, the andriod app I'm making to connect to my private MQTT broker, only works when I'm on a WIFI connection. The private broker has been correctly set up with port forwarding etc, and fully tested. So it's not a 'local' connectivity issue. n.b. I can connect to the broker on my laptop from outside my network.... so it's deffinately not a broker issue.

I've tried a number of things, but the most interesting, is when I connect my phone, to my wife's phone which is set to a wireless hotspot, the app will only connect when her phone has WiFi enabled (i.e my phone --> wireless hot spot (wife's phone) --> local Wifi network). As soon as I disable it to force the traffic through the cellular network, my MQTT client stops.

I was initially wondering if it could have been a permissons issue in my app, but I've read/watched everything I can find, and I think I have added the correct permissions.

I'm now leaning towards it being an issue with Telstra, but I'm not sure where to go to now. I have also tried some apps other people have written, and they seem to experience the same problem. Could it be Telstra not allowing port 1883, and if so, is there a way to get around it, or perhaps a specific section of code to 'force' the phone to do it?

I've included the relevant code snipits below.

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

and

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

本文标签: androidMQTT app connects on WIFI but not on mobile dataStack Overflow