Android Question Ports and Debugging: B4A-Bridge vs. ADB - What's the Difference?

Hi everyone,

I'm trying to understand the networking setup involved when debugging a B4A app, specifically when using B4A-Bridge versus using ADB (either via USB or TCP). I'm getting a bit confused about which ports are used in each scenario, and what the fundamental differences are. I'm hoping some of the experts here can clarify.

Here are my specific questions:

  1. B4A-Bridge Ports: When I use B4A-Bridge to connect my device to the B4A IDE for debugging, what ports are involved? Is it just one specific port, or a range? Is the port number fixed, or does it vary? I am guessing that a port is open on the device, and the IDE connects to it. Is this correct? Does a port also needs to be open on my development PC?
  2. B4A-Bridge vs. ADB (USB/TCP): What are the key differences between using B4A-Bridge and using ADB (either through a USB connection or ADB over TCP/IP) for debugging, in terms of network communication?
  3. ADB Port Forwarding (if applicable): If I'm using ADB over TCP/IP, I understand I might need to use adb forward. How does this relate to the ports used by B4A itself during debugging? Are we forwarding the B4A debugging port, or is it something else?
  4. Security: Are there any security differencies between those methods?
  5. Concrete Example (if possible): Could someone provide a concrete example of the ports typically used in both scenarios (B4A-Bridge and ADB TCP/IP)? For instance:
    • B4A-Bridge: "B4A IDE (PC) uses [Port X] to connect to the B4A-Bridge app on the device (listening on [Port Y])."
    • ADB TCP/IP: "ADB uses [Port A] on the PC and [Port B] on the device. B4A debugging communication happens over [possibly different ports, or maybe the same ones?], which are forwarded by ADB."
    It is very important to understand if there are firewalls involved.
I've read through the documentation, but I'm still a little hazy on these low-level details. Understanding this will help me troubleshoot connection issues and better grasp the debugging process. Any help in untangling this would be greatly appreciated!

Thanks in advance!
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
looking at netstat from my PC while debugging, I see that B4A Bridge seems to listen only on port 6789/TCP.
Just this connection from PC to Phone.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Understanding this will help me troubleshoot connection issues
Just so you know: Connection issues are very rare, it works like clockwork for the vast majority of developers.

Don't let that stop you from understanding things though, I just wanted you to know it's a solid solution.
 
Upvote 0
Thanks to everyone for your input so far! It is very helpful. I'm not questioning that the usual setup of B4A is stable; unfortunately, due to security policies, our network is heavily firewalled, and nearly all ports are closed.

After opening port 6789/TCP, B4A does recognize the device, and I can successfully install the debug APK. However, when I launch the app, it hangs waiting for the B4A debugger, and it seems like it never receives a response.

Using adb logcat, I observed that immediately after the app starts on the device, it opens a port that appears to consistently be 17710. My assumption is that this is a default port used by B4A when it wraps the app and includes the debug handling logic.

My main question now is:
  • Is port 17710 always the port used for debugger communication in this scenario (B4A-Bridge, with the IDE waiting for a connection), or is it within a range of possible ports? Knowing this is crucial for configuring the firewall correctly.
  • Firewall configuration. To be sure to correctly configure the firewall, it is important to know if, in my scenario (B4A-Bridge), do I have to open the 17710/tcp port as inbound on the PC, or as outbound on the Android device (or both)?

If anyone can confirm whether this port is fixed or if there's a range, I'd be very grateful. It would allow us to create a very specific firewall rule and avoid opening more ports than necessary.
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
In the wide but small rectangle with the magnifying glass at the top of the window here or in any thread, enter: "What port does B4A bridge use" and click enter? You will find that several people have had similar ideas and problems like you explain here. This is how you can help yourself and needn't wait for responses from others.
 
Last edited:
Upvote 0
Top