Configuring FTP Active / Passive Using Java URLConnection

Is it possible to set FTP passive or active mode when working with the URLConnection class? I can’t find the documentation for this, but it’s such basic functionality that it’s hard to believe that it is not implemented.

If this is not the case, what other parameters do I have in standard Java?

+4
source share
2 answers

To get full FTP access, you really need to go back to low-level programming with Sockets . URLConnection and spouses simply do not meet your needs (there is no support for entering passive mode). Fortunately, Apache Commons has already done a lot for you in the flavor of Apache Commons Net FTPClient . To achieve what you need, just use FTPClient#enterLocalPassiveMode() or FTPClient#enterLocalActiveMode()

+8
source

Today we capture the TCP / IP packet and confirm that Android / JAVA / URLConnection still uses PORT (active mode) for FTP.

If the server does not support active mode or the network does not support active mode, URLConnection will not be performed.

0
source

Source: https://habr.com/ru/post/1301603/


All Articles