zoukankan      html  css  js  c++  java
  • http超时机制



    HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {

                    @Override
                    public boolean retryRequest(IOException exception, int arg1, HttpContext arg2) {
                        if (arg1 >= 3) {
                            return false;
                        }
                        if (exception instanceof InterruptedIOException) {
                            // Timeout
                            return true;
                        }
                        if (exception instanceof UnknownHostException) {
                            // Unknown host
                            return true;
                        }
                        if (exception instanceof ConnectTimeoutException) {
                            // Connection refused
                            return true;
                        }
                        if (exception instanceof SocketTimeoutException) {
                            // Connection refused
                            return true;
                        }
                        if (exception instanceof SSLException) {
                            // SSL handshake exception
                            return false;
                        }
                        return false;
                    }
                };

                CloseableHttpClient httpclient = HttpClients.custom().setRetryHandler(myRetryHandler)
                        .setDefaultRequestConfig(globalConfig).setMaxConnTotal(100).build();

  • 相关阅读:
    Air-WIFI使用方法
    libeasy代码学习:一次简单的TCP请求处理流程
    log_pipe日志收集分析系统介绍
    asp.net 项目在 IE 11 下出现 “__doPostBack”未定义 的解决办法
    用命令行实现“一键休眠”
    C#几个经常用到的字符串的截取
    MYSQL存储过程怎么写
    如何用myeclipse和eclipse搭建安卓开发环境
    C#随机生成不重复字符串
    Inno setup 简单打包教程
  • 原文地址:https://www.cnblogs.com/gkbgy/p/7574553.html
Copyright © 2011-2022 走看看