加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

MySQL / PHP错误:[2002]凡是只应承行使每个套接字地点(协议/网

发布时间:2021-04-02 05:20:28 所属栏目:编程 来源:网络整理
导读:我无法在stackoverflow上找到办理方案,大大都其他相干主题都与Apache没有先启动并呈现此错误有关.我的题目是,在apache运行后,我的一些用户毗连到我们的php / mysql网站将收到此错误: PHP Warning: mysql_connect() [function.mysql-connect]:[2002] Only on

我无法在stackoverflow上找到办理方案,大大都其他相干主题都与Apache没有先启动并呈现此错误有关.我的题目是,在apache运行后,我的一些用户毗连到我们的php / mysql网站将收到此错误:

PHP Warning:  mysql_connect() [function.mysql-connect]:
[2002] Only one usage of each socket address (protocol/network address/port)
is normally permitted.

这好像是完全随机的,当我监督Apache的事变线程时,凡是有很多空闲事变者可以接管新的毗连/哀求.

我的网站运行在Windows XP SP3,Xampp 1.7.7,四核,4GB内存,1TB HD,php / mysql类型:

Apache / 2.2.21(Win32)mod_ssl / 2.2.21 OpenSSL / 1.0.0e PHP / 5.3.8 mod_perl / 2.0.4 Perl / v5.10.1

任何辅佐我应该改变我的任何设置,以使其消散将不胜谢谢.我已经看过谷歌,乃至在Xampp论坛上,可是大大都人在启动Apache之前城市碰着这个题目,可是当用户碰着这个错误时,Apache运行正常.

最佳谜底 该错误现实上并非来自MySQL,而是from Windows itself:

When a connection is closed,on the side that is closing the connection the 5 tuple
{ Protocol,Local IP,Local Port,Remote IP,Remote Port} goes into a TIME_WAIT state for 240 seconds by default.

In this case,the protocol is fixed – TCP

The local IP,remote IP and remote PORT are also typically fixed. So the variable is the local port.

What happens is that when you don’t bind a port in the range 1024-5000 is used.
So roughly you have 4000 ports. If you use all of them in 4 minutes – meaning roughly you
make 16 web service calls per second for 4 minutes you will exhaust all the ports. That is the cause of this exception.

换句话说,您已经耗尽了动态范畴内的端口.那也许不该该产生.你在这里处理赏罚几多并发用户?

链接的博客有办理要领:

>通过注册表编辑增进动态端口范畴.
>通过注册表编辑镌汰体系但愿在TIME_WAIT中耗费的毗连的时刻.
>运行一些代码来执行上述注册表编辑而不行使regedit.

各类百般的办理要领!

另见this question on the Visual Studio forums,其表明如下:

The port will be locked for another minute or two to catch all packets which might have been sent before the application was terminated but haven’t arrived yet. In Winsock API you can set socket option SO_REUSEADDR to resolve this (also this option can be set in .NET Socket class),but TcpListener is too high-level and doesn’t let you set this option.

毗连MySQL的底层代码或处理赏罚Apache毗连的代码很也许不会实行行使SO_REUSEADDR.

我敢赌博,改变keepalive超时会对此发生直接影响.纵然从理论上镌汰它开释套接字,Windows也差异意并保存套接字保存.

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读