- 浏览: 1251236 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (461)
- 心得体会 (166)
- Hibernate (9)
- Spring (12)
- Struts1 (3)
- Ajax (4)
- Java (54)
- 其他技术 (21)
- 数据库 (29)
- EXT (0)
- Struts2 (7)
- Xml (3)
- HTML (5)
- JavaScript (12)
- 面试相关 (3)
- BLOG (11)
- 计算机 (11)
- PMP (0)
- OGNL (1)
- LINUX (79)
- AIX (1)
- Ubuntu (14)
- Android (1)
- hadoop (3)
- LINUX debian (3)
- 心得体会 eclipse (2)
- JSTL (1)
- 心得体会 hadoop cdh3u5 (2)
- maven (5)
- Hive (1)
- 心得体会 工具使用 (3)
- spring data jpa Query By Example(QBE) (1)
- nginx (2)
- Apache (1)
- mysql (6)
- LINUX mysql (2)
- freemaker (1)
- 心得体会 FastDFS Nginx 断点续传 (1)
- LINUX FastDFS Nginx 断点续传 (1)
- 心得体会 Mybatis (2)
- 心得体会 mysql (4)
- php (1)
- logback 简介 (5)
- EL (1)
- Tomcat (2)
- win7 (1)
- LINUX maven (1)
- scrumworks (1)
- linux nginx (6)
- svn linux (1)
- mac (3)
- mac git (1)
- git (1)
- nexus (2)
- golang (1)
- LINUX Redis (1)
- mac oracle (1)
最新评论
-
a785975139:
有用
MySQL Error :SHOW PROFILES -
yijiulove:
弄了半天,参照你的方法解决了.特来感谢,知道可能是先加载,但是 ...
Spring和Mybatis整合时无法读取properties的处理方案 -
chenjinqi1987:
Missing com.sun.jdmk:jmxtools:jar:1.2.1 -
leifeng2:
请问怎么使用,运行之后d盘符没有生产音频文件呢?
java录音程序 -
sundful:
chenghong726 写道你好,我也遇到你这样的问题,按照 ...
Spring和Mybatis整合时无法读取properties的处理方案
解决方法:
在网络编程中,特别是在短时间内new的网络连接太多,经常出现java.net.BindException: Address already in use: JVM_Bind的异常,网络有很多介绍此异常的,通常都是在说是要使用的端口被别的程序已经使用,但有时并不是这个原因,通过仔细查找,找到一些很好的资料,在此将其一一记录下来。
**********************************************************************
文章一
短时间内new socket操作过多
而socket.close()操作并不能立即释放绑定的端口
而是把端口设置为TIME_WAIT状态
过段时间(默认240s)才释放(用netstat -na可以看到)
最后系统资源耗尽
(windows上是耗尽了pool of ephemeral ports 这段区间在1024-5000之间)
Socket FAQ:
Remember that TCP guarantees all data transmitted will be delivered,
if at all possible. When you close a socket, the server goes into a
TIME_WAIT state, just to be really really sure that all the data has
gone through. When a socket is closed, both sides agree by sending
messages to each other that they will send no more data. This, it
seemed to me was good enough, and after the handshaking is done, the
socket should be closed. The problem is two-fold. First, there is no
way to be sure that the last ack was communicated successfully.
Second, there may be "wandering duplicates" left on the net that must
be dealt with if they are delivered.
Andrew Gierth (andrew@erlenstar.demon.co.uk) helped to explain the
closing sequence in the following usenet posting:
Assume that a connection is in ESTABLISHED state, and the client is
about to do an orderly release. The client's sequence no. is Sc, and
the server's is Ss. Client Server
====== ======
ESTABLISHED ESTABLISHED
(client closes)
ESTABLISHED ESTABLISHED
RESOLUTIONWarning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.
The default maximum number of ephemeral TCP ports is 5000 in the products that are included in the 'Applies to' section. A new parameter has been added in these products. To increase the maximum number of ephemeral ports, follow these steps: 1.Start Registry Editor.2.Locate the following subkey in the registry, and then click Parameters: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3.On the Edit menu, click New, and then add the following registry entry: Value Name: MaxUserPort
Value Type: DWORD
Value data: 65534
Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)
Description: This parameter controls the maximum port number that is used when a program requests any available user port from the system. Typically , ephemeral (short-lived) ports are allocated between the values of 1024 and 5000 inclusive.
4.Quit Registry Editor.Note An additional TCPTimedWaitDelay registry parameter determines how long a closed port waits until the closed port can be reused.
原文连接:http://blog.chinaunix.net/u/29553/showart_450701.html
**********************************************************************
文章二
java.net.BindException: Address already in use: connect的问题
大概原因是短时间内new socket操作很多,而socket.close()操作并不能立即释放绑定的端口,而是把端口设置为TIME_WAIT状态,过段时间(默认240s)才释放,(用netstat -na可以看到),最后系统资源耗尽(windows上是耗尽了pool of ephemeral ports ,这段区间在1024-5000之间; )
避免出现这一问题的方法有两个,一个是调高你的web服务器的最大连接线程数,调到1024,2048都还凑合,以resin为例,修改resin.conf中的thread-pool.thread_max,如果你采用apache连resin的架构,别忘了再调整apache;
另一个是修改运行web服务器的机器的操作系统网络配置,把time wait的时间调低一些,比如30s。
在red hat上,查看有关的选项,
[xxx@xxx~]$ /sbin/sysctl -a|grep net.ipv4.tcp_tw
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_tw_recycle = 0
[xxx@xxx~]$vi /etc/sysctl,修改
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
[xxx@xxx~]$sysctl -p,使内核参数生效
socket-faq中的这一段讲time_wait的,摘录如下:
2.7. Please explain the TIME_WAIT state.
Remember that TCP guarantees all data transmitted will be delivered,
if at all possible. When you close a socket, the server goes into a
TIME_WAIT state, just to be really really sure that all the data has
gone through. When a socket is closed, both sides agree by sending
messages to each other that they will send no more data. This, it
seemed to me was good enough, and after the handshaking is done, the
socket should be closed. The problem is two-fold. First, there is no
way to be sure that the last ack was communicated successfully.
Second, there may be "wandering duplicates" left on the net that must
be dealt with if they are delivered.
Andrew Gierth (andrew@erlenstar.demon.co.uk) helped to explain the
closing sequence in the following usenet posting:
Assume that a connection is in ESTABLISHED state, and the client is
about to do an orderly release. The client's sequence no. is Sc, and
the server's is Ss. Client Server
====== ======
ESTABLISHED ESTABLISHED
(client closes)
ESTABLISHED ESTABLISHED
------->>
FIN_WAIT_1
<<--------
FIN_WAIT_2 CLOSE_WAIT
<<-------- (server closes)
LAST_ACK
, ------->>
TIME_WAIT CLOSED
(2*msl elapses...)
CLOSED
Note: the +1 on the sequence numbers is because the FIN counts as one
byte of data. (The above diagram is equivalent to fig. 13 from RFC
793).
Now consider what happens if the last of those packets is dropped in
the network. The client has done with the connection; it has no more
data or control info to send, and never will have. But the server does
not know whether the client received all the data correctly; that's
what the last ACK segment is for. Now the server may or may not care
whether the client got the data, but that is not an issue for TCP; TCP
is a reliable rotocol, and must distinguish between an orderly
connection close where all data is transferred, and a connection abort
where data may or may not have been lost.
So, if that last packet is dropped, the server will retransmit it (it
is, after all, an unacknowledged segment) and will expect to see a
suitable ACK segment in reply. If the client went straight to CLOSED,
the only possible response to that retransmit would be a RST, which
would indicate to the server that data had been lost, when in fact it
had not been.
(Bear in mind that the server's FIN segment may, additionally, contain
data.)
DISCLAIMER: This is my interpretation of the RFCs (I have read all the
TCP-related ones I could find), but I have not attempted to examine
implementation source code or trace actual connections in order to
verify it. I am satisfied that the logic is correct, though.
More commentarty from Vic:
The second issue was addressed by Richard Stevens (rstevens@noao.edu,
author of "Unix Network Programming", see ``1.5 Where can I get source
code for the book [book title]?''). I have put together quotes from
some of his postings and email which explain this. I have brought
together paragraphs from different postings, and have made as few
changes as possible.
From Richard Stevens (rstevens@noao.edu):
If the duration of the TIME_WAIT state were just to handle TCP's full-
duplex close, then the time would be much smaller, and it would be
some function of the current RTO (retransmission timeout), not the MSL
(the packet lifetime).
A couple of points about the TIME_WAIT state.
o The end that sends the first FIN goes into the TIME_WAIT state,
because that is the end that sends the final ACK. If the other
end's FIN is lost, or if the final ACK is lost, having the end that
sends the first FIN maintain state about the connection guarantees
that it has enough information to retransmit the final ACK.
o Realize that TCP sequence numbers wrap around after 2**32 bytes
have been transferred. Assume a connection between A.1500 (host A,
port 1500) and B.2000. During the connection one segment is lost
and retransmitted. But the segment is not really lost, it is held
by some intermediate router and then re-injected into the network.
(This is called a "wandering duplicate".) But in the time between
the packet being lost & retransmitted, and then reappearing, the
connection is closed (without any problems) and then another
connection is established between the same host, same port (that
is, A.1500 and B.2000; this is called another "incarnation" of the
connection). But the sequence numbers chosen for the new
incarnation just happen to overlap with the sequence number of the
wandering duplicate that is about to reappear. (This is indeed
possible, given the way sequence numbers are chosen for TCP
connections.) Bingo, you are about to deliver the data from the
wandering duplicate (the previous incarnation of the connection) to
the new incarnation of the connection. To avoid this, you do not
allow the same incarnation of the connection to be reestablished
until the TIME_WAIT state terminates.
Even the TIME_WAIT state doesn't complete solve the second problem,
given what is called TIME_WAIT assassination. RFC 1337 has more
details.
o The reason that the duration of the TIME_WAIT state is 2*MSL is
that the maximum amount of time a packet can wander around a
network is assumed to be MSL seconds. The factor of 2 is for the
round-trip. The recommended value for MSL is 120 seconds, but
Berkeley-derived implementations normally use 30 seconds instead.
This means a TIME_WAIT delay between 1 and 4 minutes. Solaris 2.x
does indeed use the recommended MSL of 120 seconds.
A wandering duplicate is a packet that appeared to be lost and was
retransmitted. But it wasn't really lost ... some router had
problems, held on to the packet for a while (order of seconds, could
be a minute if the TTL is large enough) and then re-injects the packet
back into the network. But by the time it reappears, the application
that sent it originally has already retransmitted the data contained
in that packet.
Because of these potential problems with TIME_WAIT assassinations, one
should not avoid the TIME_WAIT state by setting the SO_LINGER option
to send an RST instead of the normal TCP connection termination
(FIN/ACK/FIN/ACK). The TIME_WAIT state is there for a reason; it's
your friend and it's there to help you :-)
I have a long discussion of just this topic in my just-released
"TCP/IP Illustrated, Volume 3". The TIME_WAIT state is indeed, one of
the most misunderstood features of TCP.
I'm currently rewriting "Unix Network Programming" (see ``1.5 Where
can I get source code for the book [book title]?''). and will include
lots more on this topic, as it is often confusing and misunderstood.
An additional note from Andrew:
Closing a socket: if SO_LINGER has not been called on a socket, then
close() is not supposed to discard data. This is true on SVR4.2 (and,
apparently, on all non-SVR4 systems) but apparently not on SVR4; the
use of either shutdown() or SO_LINGER seems to be required to
guarantee delivery of all data.
原文连接:http://hi.baidu.com/w_ge/blog/item/105877c6a361df1b9c163d21.html
文章三
当您尝试从 TCP 端口大于 5000 连接收到错误 ' WSAENOBUFS (10055) '
症状如果您尝试建立 TCP 连接从端口是大于 5000, 本地计算机响应并以下 WSAENOBUFS (10055) 错误信息: 因为系统缺乏足够缓冲区空间或者因为队列已满无法执行套接字上操作。
解决方案要点 此部分, 方法或任务包含步骤告诉您如何修改注册表。 但是, 如果修改注册表错误可能发生严重问题。 因此, 确保仔细执行这些步骤。 用于添加保护之前, 修改备份注册表。 然后, 在发生问题时还原注册表。 有关如何备份和还原注册表, 请单击下列文章编号以查看 Microsoft 知识库中相应:
默认最大数量的短暂 TCP 端口为 5000 ' 适用于 ' 部分中包含产品中。 这些产品中已添加新参数。 要增加最大值是短暂端口, 请按照下列步骤操作:
1.启动注册表编辑器。 2.注册表, 中找到以下子项, 然后单击 参数 : HKEY _ LOCAL _ MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3.在 编辑 菜单, 单击 新建 , 然后添加以下注册表项: MaxUserPort 值名称:
值类型: DWORD
值数据: 65534
有效范围: 5000 - 65534 (十进制)
默认: 0x1388 5000 (十进制)
说明: 此参数控制程序从系统请求任何可用用户端口时所用最大端口数。 通常, 1024 的值和含 5000 之间分配临时 (短期) 端口。
4.退出注册表编辑器, 并重新启动计算机。 注意 一个附加 TCPTimedWaitDelay 注册表参数决定多久关闭端口等待可以重用关闭端口。
对应英文原文为:
SYMPTOMSIf you try to set up TCP connections from ports that are greater than 5000, the local computer responds with the following WSAENOBUFS (10055) error message: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
RESOLUTIONImportant This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 (http://support.microsoft.com/kb/322756/) How to back up and restore the registry in Windows
The default maximum number of ephemeral TCP ports is 5000 in the products that are included in the 'Applies to' section. A new parameter has been added in these products. To increase the maximum number of ephemeral ports, follow these steps:
1.Start Registry Editor. 2.Locate the following subkey in the registry, and then click Parameters: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3.On the Edit menu, click New, and then add the following registry entry: Value Name: MaxUserPort
Value Type: DWORD
Value data: 65534
Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)
Description: This parameter controls the maximum port number that is used when a program requests any available user port from the system. Typically , ephemeral (short-lived) ports are allocated between the values of 1024 and 5000 inclusive.
4.Exit Registry Editor, and then restart the computer. Note An additional TCPTimedWaitDelay registry parameter determines how long a closed port waits until the closed port can be reused.
发表评论
-
MySQL 5.6 my.cnf 配置
2015-11-03 17:48 3317[client] port = 3306 socket ... -
mysql将查询结果导出csv文件的方法into outfile
2015-10-22 15:41 1302例句: select * from table_name ... -
MySQL时区设置
2013-11-15 18:20 1324MySQL 时区默认是服务器的时区。可以通过以下命令查看 ... -
MYSQL存储过程中 表名 使用变量
2013-08-21 15:44 2180# 该存储过程定义了几个传入参数,前缀都是para ... -
MySQL Error :SHOW PROFILES
2011-05-20 16:51 3234在使用SQLyog Enterprise V8.1 英文版的时 ... -
Mysql连接问题:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
2011-05-16 14:08 25636com.mysql.jdbc.exceptions.jdbc4 ... -
Hibernate 使用内连接(hql) 使用左外连接 命名的hql 命名的sql 调用存储过程Oracle 等
2011-03-22 11:24 3061使用内连接(hql)from Product p inne ... -
MYSQL错误 NO.1130 ERROR的解决
2010-10-20 08:48 2612如果你想连接你的mysql的时候发生这个错误: ERROR ... -
用JDBC操纵BLOB和CLOB数据
2010-08-09 10:12 1855在访问Oracle 数据库,对Oracle 的BLOB 和CL ... -
解决Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'
2010-07-02 14:28 12375Mysql ERROR 1045 (28000): Acces ... -
linux忘记mysql root密码的解决方法
2010-07-02 14:27 1551方法如下: 1, 关闭mysql服务 /etc/init.d/ ... -
Oracle 创建表空间、创建用户以及授权、查看权限
2010-05-25 11:03 1571创建临时表空间 创建临时表空间 CREATE ... -
ORA-01720
2010-05-13 14:31 5305对我来说权限方面是本人最反感的部分之一,但作为开发DBA ... -
Windows下ORACLE的完全卸载
2010-05-13 08:24 1443Windows下ORACLE完全卸载: ... -
Oracle中创建视图,提示无权限 ORA-01031
2010-05-11 17:24 4593今天在对表创建视图的时候,用户提示 ORA-01031用户权限 ... -
Oracle用户权限管理
2010-05-10 17:52 1469sys;//系统管理员,拥有最高权限 system ... -
oracle恢复误删除数据
2010-05-07 14:19 12491.曾经不小心把开发库的数据库表全部删除,当时吓的要死。结果找 ... -
Powerdesigner连接Mysql数据库配置图解
2010-03-03 11:02 4433Powerdesigner 由 ... -
PL/SQL Developer 不得不知的技巧
2009-04-24 17:43 14621、PL/SQL Developer记住登 ... -
PowerDesigner 12 官方视频教程
2009-02-10 10:08 8725最近找PowerDesigner的相关资料.今天找到这个好东东 ...
相关推荐
【Java中的`java.net.BindException: Address already in use: JVM_Bind`异常】 在Java编程中,当你尝试启动一个服务器端应用,如Tomcat,或者任何需要监听特定端口的服务时,可能会遇到`java.net.BindException: ...
在myeclipse中将html文件改成jsp文件时myeclipse卡住;将之前的任务关掉;再打开时多次部署项目的时候报错
在Android开发过程中,网络通信是应用的重要组成部分,而使用UDP(User Datagram Protocol)进行数据传输时,可能会遇到`java.net.BindException: bind failed: EADDRINUSE`的问题。这个异常通常意味着应用程序尝试...
nested exception is: java.net.BindException: Address already in use: JVM_Bind 这里说的是1099端口被其它进程占用了. 二.解决办法 找出占用1099端口的进程,进入windows命令,查看什么进程占用了1099端口...
使用JMeter压测时,报java.net.bindexception:address already is use:connect异常,可执行本资源的.bat文件,修改系统注册表。
jemeter 最初被设计用于 Web 应用测试,但后来扩展到了其他测试领域,可用于测试静态和动态资源,如静态文件、Java 小服务程序、CGI 脚本、Java 对象、数据库和 FTP 服务器等等。 jemeter 可对服务器、网络或对象...
1. **java.net.BindException: Address already in use: JVM_Bind** 这个异常表明尝试绑定的端口已被其他服务占用。解决方法是检查并更改端口号,选择一个未被使用的端口。使用`netstat -an`命令可以帮助识别哪些...
在开发基于Java Netty的应用程序时,可能会遇到`java.net.BindException: Address already in use: no further information`这类错误。本篇文章将详细解析这一异常的原因、可能的影响以及如何有效地解决该问题。 ##...
常见的问题
java.net.BindException: Address already in use 该异常发生在服务器端进行 new ServerSocket(port) 操作时,原因是因为与 port 相同的端口已经被占用,解决方法是找到一个空闲的端口。 java.net....
在Java中,当我们使用`ServerSocket`类创建服务器并指定一个端口时,如果该端口已经被另一个进程占用,`bind()`方法会抛出`BindException`,具体表现为"Address already in use"。在`java.net.ServerSocket`类的源码...
nested exception is: java.net.BindException: Address already in use: JVM_Bind 这提示是 1099 端口被占用了。这是因为 Tomcat 服务器需要使用 1099 端口来启动,但是这个端口已经被其他应用程序占用了。 解决...
vhost WARN 200 - _defaultVHost_Bind failed, try again ([any]:1935): java.net.BindException: Address already in use ``` **原因分析:** 该错误通常发生在同一台服务器上有多个WowzaMediaServer实例同时运行...
java.net.BindException: Address already in use: JVM_Bind 当尝试通过`new ServerSocket(port)`创建一个服务器套接字,并指定端口号`port`(该值应在0到65536之间)时,如果出现此异常,表明所指定的端口已被...
Reason: java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to java.net.BindException: Address already in use: JVM_Bind”...
"卸载工具007"是一款专为用户设计的高效、便捷的软件卸载应用程序,旨在帮助用户彻底、干净地从计算机中移除不需要的软件。"完美"这个描述可能是指该工具在卸载过程中能确保不留任何残留,提供一种无瑕疵的卸载体验...
4. **java.net.BindException: Address already in use: JVM_Bind**:这意味着8080端口已被其他服务占用。你可以通过修改Tomcat配置文件`server.xml`来改变Tomcat的默认端口,如示例所示,将端口改为80或其他未使用...
端口冲突java.net.BindException: Address already in use: JVM_Bind java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory deploy(部署)项目。点击 deploy 按钮,在弹出的Project Deployments...
2,localhost: java.net.BindException: Address already in use 3,ERROR: org.apache.hadoop.hbase.MasterNotRunningException: Retried 7 times 4,ERROR: org.apache.hadoop.hbase.MasterNotRunningException: ...