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

Discussion in 'Tutorials & Examples' started by Erel, May 28, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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:
    Code:
    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: May 29, 2018
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice