压测时,应用服务器报错:Cannot assign requested address (connect failed)

经检查,由于应用服务器,频繁发起http请求,由于每次连接都在很短的时间内结束,导致很多的TIME_WAIT,以至于用光了可用的端 口号,所以新的连接没办法绑定端口

“Cannot assign requested address.”是由于linux分配的客户端连接端口用尽,无法建立socket连接所致,虽然socket正常关闭,但是端口不是立即释放,而是处于TIME_WAIT状态,默认等待60s后才释放。

解决方法:

1、程序中每次http请求完成后,关闭http连接

finally{
httpclient.getConnectionManager().shutdown();
}

2、调低端口释放后的等待时间,默认为60s,修改为15~30s

sysctl -w net.ipv4.tcp_fin_timeout=30

3、修改tcp/ip协议配置, 通过配置/proc/sys/net/ipv4/tcp_tw_resue, 默认为0,修改为1,释放TIME_WAIT端口给新连接使用

sysctl -w net.ipv4.tcp_timestamps=1

4、修改tcp/ip协议配置,快速回收socket资源,默认为0,修改为1

sysctl -w net.ipv4.tcp_tw_recycle=1

设置完应用服务器参数后,执行命令“sysctl -p”使参数生效

Cannot assign requested address (connect failed)的更多相关文章

  1. Eclipse中Tomcat Server启动后马上又自动停止报错Address已经使用8005端口 Can't assign requested address (Bind failed)

    Eclipse中Tomcat Server启动后马上又自动停止报错 Can't assign requested address (Bind failed) ,打开Tomcat Server的配置页面 ...

  2. Cannot assign requested address 和 SO_REUSEADDR 参数

    1. 错误 今天项目中出现了大量的java.net.ConnectException: Cannot assign requested address (connect failed) 错误. 刚开始 ...

  3. connect() to 192.168.30.71:8082 failed (99: Cannot assign requested address) while connecting to upstream, client: 114.80.182.136, server: localhost, request: "GET /home/senior HTTP/1.1", upstream: "

    connect() to 192.168.30.71:8082 failed (99: Cannot assign requested address) while connecting to ups ...

  4. 【ERROR】ERROR: transport error 202: bind failed: Cannot assign requested address

    异常信息: ERROR: transport error : bind failed: Cannot assign requested address ERROR: JDWP Transport dt ...

  5. kafka.common.KafkaException: Socket server failed to bind to hdp1:9092: Cannot assign requested address.

    ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.K ...

  6. java.net.BindException: Cannot assign requested address: bind

    异常信息 时间:2017-03-16 10:21:05,644 - 级别:[ERROR] - 消息: [other] Failed to start end point associated with ...

  7. tomcat启动端口号报错java.net.BindException: Cannot assign requested address

    异常信息 时间:2017-02-09 15:09:59,829 - 级别:[ERROR] - 消息: [other] Failed to start end point associated with ...

  8. php连接memcahed出现Cannot assign requested address (99)的解决方法

    今天在将服务器合并后,发现php偶尔会报出 Server *.*.*.* (tcp *****) failed with: Cannot assign requested address (99) 的 ...

  9. ElasticSearch 6.4.3 启动报错: [Cannot assign requested address: bind]

    今天在本地搭建一个测试用的最新版ElasticSearch6.4.3 的环境时,遇到一个报: [Cannot assign requested address: bind]的错误. 错误日志内容如下: ...

随机推荐

  1. JSP的域对象的作用范围

    <%-- Created by IntelliJ IDEA. User: tT丶 Date: 2017-12-12 Time: 14:53 To change this template use ...

  2. HDU 1009 FatMouse' Trade(简单贪心)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1009 FatMouse' Trade Time Limit: 2000/1000 MS (Java/O ...

  3. Google 和 Baidu 常用的搜索技巧

    Google 常用的搜索技巧 1. 精确搜索:双引号 精确搜索,就是在你要搜索的词上,加上双引号,这个Google搜索引擎,就会完全的匹配你所要的词 2. 站内搜索:site 这是一个比较常用的搜索方 ...

  4. c++11线程创建的三种方法

    一.用一个初始函数创建一个线程 直接看代码:注意c++在运行一个可执行程序的时候(创建了一个进程),会自动的创建一个主线程,这个主线程和进程同生共死,主线程结束,进程也就结束了. #include & ...

  5. ABAP术语-Transaction

    Transaction 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/19/1112804.html Logical process in ...

  6. Zabbix——创建网络配置模板

    前提条件: Zabbix版本为4.0 创建网络配置模板: Template Net Network Generic Device SNMPv2 h3c Template Module EtherLik ...

  7. asp.net在一般处理程序里面操作Session

    1.要在一般处理程序中获取其他页面的session值,需要引用名空间: using System.Web.SessionState; 2.然后继承一个接口:IRequiresSessionState ...

  8. ArrayList的源码分析(基于jdk1.8)

    1.初始化 transient Object[] elementData; //实际存储元素的数组 private static final Object[] DEFAULTCAPACITY_EMPT ...

  9. java中子类会继承父类的构造方法吗?

    参考: https://blog.csdn.net/wangyl_gain/article/details/49366505

  10. day3-exercise

    # Author: 刘佳赐-Isabelle October 28,2018 """ 1. 文件a1.txt内容 序号 部门 人数 平均年龄 备注 1 python 30 ...