Android Tutorial [B4X] Tip: Always set FTP.PassiveMode to True

I've just wasted an hour trying to understand why a desktop program that I'm using for many months failed to upload a file to a FTP server.
I realized that the only thing that was recently changed is that B4J was running with Java 10. Mistakenly I assumed that it is related to IPv6 handling (the server is using IPv4).

What actually happened is that after Java 10 was installed, at some point there was a windows message asking whether I allow it to open a firewall port. I didn't allow it.
The default mode for FTP is active mode. In active mode the server needs to make an incoming connection to the client. This doesn't work on mobile / cellular networks and it doesn't work if the firewall is not configured for this.
The solution is very simple:
B4X:
FTP.Initialize(...)
FTP.PassiveMode = True

Passive mode doesn't require an incoming connections and should have been the default mode (it will not be changed in the Net library).
 
Last edited:
Top