• 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();

  • 相关阅读:
    javascript平时小例子③(setInterval使用1)
    javascript平时小例子②(正则表达式验证邮箱)
    javascript平时小例子①(移动的小div)
    Ansible主机清单Inventory文件hosts
    K8s Deployment YAML 名词解释
    Linux自带神器logrotate详解
    Redis性能指标监控
    页面无任何操作30秒后退出1
    java 加法变乘法
    java 九数组分数
  • 原文地址:https://www.cnblogs.com/gkbgy/p/7574553.html
Copyright © 2020-2023  润新知