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

  • 相关阅读:
    .net实现支付宝在线支付
    彻头彻尾理解单例模式与多线程
    Linq中的Select与Select many
    MVC中子页面如何引用模板页中的jquery脚本
    浅谈MemCahe
    左连接,右连接,内连接(left join ,right join,inner join)
    协变与逆变
    子类对父类中的属性和字段的改写
    里氏转换
    MVC基础篇—控制器与视图数据的传递
  • 原文地址:https://www.cnblogs.com/gkbgy/p/7574553.html
Copyright © 2011-2022 走看看