Android Question Remote UDP Message

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using B4A as the client side and B4J for the server side.

My B4A app is sending a UDP message to my B4J server.

In B4J I have made it listen for incoming UDP messages and when it receives the incoming UDP message to then send a reply to the Packet.Hostname and Packet.Port that sent the message.

The above works fine when I am testing it on a local WiFi network.

In my B4A app I then changed the IP address to my routers WAN IP address, and port forward (the UDP port) to my computer's IP address (since this is the IP that is hosting my B4J app)

I got my B4A app to send a UDP and it worked.

I then turned off my WiFi (so now I am connected by 3G/4G) and send the UDP message. My B4J app received the message, but the B4A app didn't get the reply.

Should I be able to reply to the B4A app while connected to the 3G/4G network using UDP or do Mobile networks block the reply ?

If I have my notebook in office and I use my phone at home (both on different WiFi networks) and test it then it works fine over the internet, so I know my port forwarding in the office is correct. I opened no ports in my router at home and it still get's the reply.

So I am guessing mobile networks block the UDP messages being returned ?

If this is blocked, is there any work a round's ?
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi,

So I am guessing mobile networks block the UDP messages being returned ?

If this is blocked, is there any work a round's ?

This is related how the mobile networks are designed; most of them (if not all) make extensive use of NAT. Better explained at http://stackoverflow.com/questions/8525867/android-broadcasting-over-3g?rq=1

You can implement a communication system with a centralized system server like MQTT Broker or Pushing system (Firebase) by token or topic to communicate between server and client ; I've a (almost finished) centralized domotic system with RPi3 with B4J and B4A app and it communicates by a combination of HTTP protocol (query server from Android device) and Firebase messassing (receiving events from server on Android device)

Which is the scenario ? (data involved and timing between queries)
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Thanks for the reply..

I had a feeling that was the case.

I think MQTT would work.
 
Upvote 0
Top