<tfoot id='iBBOf'></tfoot>

    • <bdo id='iBBOf'></bdo><ul id='iBBOf'></ul>

  • <legend id='iBBOf'><style id='iBBOf'><dir id='iBBOf'><q id='iBBOf'></q></dir></style></legend>

    <small id='iBBOf'></small><noframes id='iBBOf'>

    1. <i id='iBBOf'><tr id='iBBOf'><dt id='iBBOf'><q id='iBBOf'><span id='iBBOf'><b id='iBBOf'><form id='iBBOf'><ins id='iBBOf'></ins><ul id='iBBOf'></ul><sub id='iBBOf'></sub></form><legend id='iBBOf'></legend><bdo id='iBBOf'><pre id='iBBOf'><center id='iBBOf'></center></pre></bdo></b><th id='iBBOf'></th></span></q></dt></tr></i><div id='iBBOf'><tfoot id='iBBOf'></tfoot><dl id='iBBOf'><fieldset id='iBBOf'></fieldset></dl></div>

        FTP 连接太多,无法接受更多

        时间:2023-10-30

      1. <i id='xmO87'><tr id='xmO87'><dt id='xmO87'><q id='xmO87'><span id='xmO87'><b id='xmO87'><form id='xmO87'><ins id='xmO87'></ins><ul id='xmO87'></ul><sub id='xmO87'></sub></form><legend id='xmO87'></legend><bdo id='xmO87'><pre id='xmO87'><center id='xmO87'></center></pre></bdo></b><th id='xmO87'></th></span></q></dt></tr></i><div id='xmO87'><tfoot id='xmO87'></tfoot><dl id='xmO87'><fieldset id='xmO87'></fieldset></dl></div>

          • <bdo id='xmO87'></bdo><ul id='xmO87'></ul>
                <tbody id='xmO87'></tbody>

              <small id='xmO87'></small><noframes id='xmO87'>

              <legend id='xmO87'><style id='xmO87'><dir id='xmO87'><q id='xmO87'></q></dir></style></legend>
              • <tfoot id='xmO87'></tfoot>

                  本文介绍了FTP 连接太多,无法接受更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我收到以下错误消息:

                  <块引用>

                  警告: ftp_login():我在第 58 行的 C:xampphtdocs estftp_sync.php 中不能以同一用户接受超过 6 个连接

                  导致错误的代码:

                  函数 newStream($i){$conId = ftp_connect($this->ftpServer);//使用用户名和密码登录$login_result = ftp_login($conId, $this->ftpUsername, $this->ftpPassword);//第58行///home/content/61/10367861/html///开启被动模式ftp_pasv($conId, true);$this->conIds[$i]=$conId;$this->localFiles[$i]='';$this->conStats[$i]=FTP_FAILED;//初始值}

                  有没有人知道这个错误信息是什么意思?

                  解决方案

                  抛出此错误是因为您的服务器限制了每个用户/IP 地址的最大连接数.大多数人遇到的错误大多是这样的:

                  <块引用>

                  421我不能接受超过 [0-9]+ 个连接作为同一用户

                  <块引用>

                  421 来自此 IP 的连接过多 ([0-9]+)

                  这种错误最常使用的FTP错误代码是421.在 RFC 959 (FTP) 中定义为:

                  <块引用>

                  421 服务不可用,正在关闭控制连接.这可能是一个如果服务知道它必须关闭,则回复任何命令.

                  您现在有两种可能的解决方案来解决这个问题:

                  1. 减少程序建立的连接数量.
                  2. 增加与您的服务器的允许 FTP 连接数量.

                  如果允许的最大值低于 3,那么您应该首先尝试更改服务器上的配置文件,因为大多数程序至少需要 3,有时需要 2.

                  1. 减少连接数量


                  在程序中遇到问题时:一些 FTP 客户端允许用户在设置中更改使用的连接数量.他们大多同时使用大约 3 个连接,2 个用于提高性能,1 个用于在用户执行其他任务时启用浏览.如果您在执行其他任务时不担心浏览,您可以将数量减少到 2 甚至 1,而不会丢失任何重要功能.(FileZilla 例如允许这样做.)

                  在您自己的代码中遇到问题时:减少并发执行的任务数量.还要检查您的代码是否以正确的方式关闭连接,以及在引发错误时.无论发生什么,它都应该始终关闭.在 PHP 中,您可以在一个类中使用 try-catch-blocks将关闭连接的代码放入__destruct 方法中.p>

                  1. 增加允许的连接数


                  这取决于您使用的 FTP 服务器类型.在 PureFTP (大多数 UNIX 系统使用)中,您需要更改 /etc/pure-ftpd.conf 中的 MaxClientsPerIP 设置.默认配置文件或托管公司的大多数管理员设置的默认数量约为 5-15.增加值,直到它适合您的需要.请注意,理论上介于最多用户和 FTP 服务器之间的代理服务器可能会导致问题,因为大多数连接将使用相同的 IP 地址.


                  在您的特殊情况下:正如 Mave 所述,您并没有关闭连接在你的代码中.这很容易导致多个连接处于活动状态,特别是如果您在短时间内多次运行代码.因此,在您的特定情况下,添加 ftp_close($conId); 可以解决问题.(也可以使用 try-catch-block.)

                  I got the following error message:

                  Warning: ftp_login(): I can't accept more than 6 connections as the same user in C:xampphtdocs estftp_sync.php on line 58

                  My code which causes the error:

                  function newStream($i){
                          $conId = ftp_connect($this->ftpServer);
                  
                          // login with username and password
                          $login_result = ftp_login($conId, $this->ftpUsername, $this->ftpPassword);//line 58
                          // /home/content/61/10367861/html/
                  
                          // turn passive mode on
                          ftp_pasv($conId, true);
                  
                          $this->conIds[$i]=$conId;
                          $this->localFiles[$i]='';
                          $this->conStats[$i]=FTP_FAILED;//initial value
                      }
                  

                  Does anyone probably know what this error message means?

                  解决方案

                  This error is thrown because your server restricts the maximum number of connections per user / IP address. The errors the most people encounter look mostly like this:

                  421 I can't accept more than [0-9]+ connections as the same user

                  421 Too many connections ([0-9]+) from this IP

                  The FTP error code which is mostly used for this kind of error is 421. Which is defined in RFC 959 (FTP) as:

                  421 Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down.

                  You have now exactly two possible solutions to solve this problem:

                  1. Reduce the amount of connections made by your program.
                  2. Increase the amount of allowed FTP connections to your server.

                  If the allowed maximum is beneath 3, then you should first try to change the config file on your server, because the most programs need at least 3, sometimes 2.

                  1. Reducing the amount of connections


                  When facing the problem within a program: Some FTP clients allow the user to change the amount of used connections in the settings. They are mostly using about 3 connections at the same time, 2 to increase the performance, 1 to enable browsing while the user is performing other tasks. You can decrease the amount without losing any important functionality to 2 or even to 1, if you don't bother about browsing while performing other tasks. (FileZilla for example allow this.)

                  When facing the problem within your own code: Reduce the amount of tasks which are performed concurrently. Check also if your code is closing the connections the right way, also when errors are thrown. It should always be closed, no matter what happens. In PHP you could use try-catch-blocks, inside a class you could put the code for closing the connection into the __destruct method.

                  1. Increase the amount of allowed connections


                  This depends on what kind of FTP server you are using. In PureFTP (used by the most UNIX systems) you need to change the MaxClientsPerIP setting in /etc/pure-ftpd.conf. The default amount set by the default configuration file or by the most administrators at hosting companies is somewhere about 5-15. Increase the value until it fits your needs. Be aware that theoretically a proxy server which is somewhere between the most users and the FTP server could cause trouble, because the most connection will then use the same IP address.


                  In your special case: As Mave mentioned, you aren't closing the connections in your code. This could easily cause multiple connections being active, especially if you are running the code in a short period of time multiple times. So, in your specific case would adding ftp_close($conId); fix the problem. (Use also a try-catch-block.)

                  这篇关于FTP 连接太多,无法接受更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 PHP 中显示最近从远程 FTP 服务器上传的图像 下一篇:使用 PHP 通过 FTP 上传文件

                  相关文章

                  <small id='V0x9G'></small><noframes id='V0x9G'>

                  <i id='V0x9G'><tr id='V0x9G'><dt id='V0x9G'><q id='V0x9G'><span id='V0x9G'><b id='V0x9G'><form id='V0x9G'><ins id='V0x9G'></ins><ul id='V0x9G'></ul><sub id='V0x9G'></sub></form><legend id='V0x9G'></legend><bdo id='V0x9G'><pre id='V0x9G'><center id='V0x9G'></center></pre></bdo></b><th id='V0x9G'></th></span></q></dt></tr></i><div id='V0x9G'><tfoot id='V0x9G'></tfoot><dl id='V0x9G'><fieldset id='V0x9G'></fieldset></dl></div>
                    <bdo id='V0x9G'></bdo><ul id='V0x9G'></ul>

                    1. <legend id='V0x9G'><style id='V0x9G'><dir id='V0x9G'><q id='V0x9G'></q></dir></style></legend>
                      <tfoot id='V0x9G'></tfoot>