FTP upload failed error 227 Entering Passive Model (222,111,8,111,10,40)

Source: Internet
Author: User
Tags ftp commands

Yesterday for an FTP problem toss a day. Problem background: There is an interface involved in uploading files, the server has replaced the FTP servers, we need to refresh the connection service side of the IP and port configuration, the code is not moving. The environment and the acceptance of the environment are tested, one to the production environment on the rest of the dish. We manually connect the FTP and upload the file is normal, is to run the interface by the program upload not. Based on the log information found after the login FTP did two things, one is to set the transmission mode to binary, one is to set the passive mode, with Apache FtpClient implementation:

Ftpclient.enterlocalpassivemode ();

From the code level to see no problem, because we did not move, so began to suspect server configuration problems, after they confirm, their FTP servers are set to be passive mode. There is a need to distinguish between the main passive mode: After the client connected to the server in the active mode, the server connects the client via the data port "active"; After the client connects to the server in passive mode, the server command port tells the client "My XX data port can be connected, you come over", so the client connects to the specified port. Server-side "passive" connection. The command port is used for transmitting FTP commands, and the data port is for uploading and downloading files. XX ports are generally not fixed and larger than 1024. Now that the server is in passive mode, it tells us a random port to upload the file. The command port on the server is 10000, and 10001-10100 is opened as the data port. But now does not pass, both sides said no problem, no way, can only grab bag:

"Welcome to FOOBAR FTP Service."

USER Wlf

331 Specify the password.

PASS 123

Successful Login.

TYPE I

Switching to Binary mode.

PASV

227 Entering Passive Mode (222,111,8,111,10,40)

OOPS:

Vsf_sysutil_recv_peek:no data

Let the server change to Active mode retry, the same as the packet capture results. This means that as long as we have the client in the program to set the passive mode, the service side whether active or passive, will be set to passive code, then it is likely that the service side again sent over the connection channel is problematic, causing the client to connect again the service side is not available. Between us and the server is connected with the intranet, the login is also based on the intranet IP, from the capture package to see the success of the login. And from the information of the error, the client set the passive mode after the server to create a new client connection using a NAT mapped external network IP, that is, the 222.111.8.111. The client intranet is not connected with the service-side extranet network, which leads to the new data transmission pipeline from the client to the server.

To sum up, the problem of the solution has three: either the service side of the external network IP to the intranet IP, or the client to use active mode to upload files, or open the client intranet to the service-side extranet network policy. The first scenario server does not agree, the reason is that they have other clients, need to provide external network; The second solution I do not know whether to open the intranet to the intranet map of the network strategy, to be confirmed; So eventually we can only change the code, the client no longer set the passive mode, Comment out the code that sets the passive mode on the line above.

FTP upload failed error 227 Entering Passive Model (222,111,8,111,10,40)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.