With Apache HttpClient, why isn't my connection timeout working?

前端 未结 3 1692
一个人的身影
一个人的身影 2020-12-03 11:34

My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set

_moHttpClient.setH         


        
3条回答
  •  既然无缘
    2020-12-03 12:26

        HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams();
        cmparams.setSoTimeout(10000);
        cmparams.setTcpNoDelay(true);
        HttpConnectionManager manager = new SimpleHttpConnectionManager();
        manager.setParams(cmparams);
        params = new HttpClientParams();
        params.setSoTimeout(5000);
        client = new HttpClient(params, manager);
    

    I wonder why I have two different SoTimeouts set. Maybe I was trying to find out which one was actually active, as I had the same problems as you when I used it.

    The above is in live code at our place right now, but I cannot say whether it works because it's correct, or because providence is smiling down on me (and the other end is usually always available).

提交回复
热议问题