本文介绍了对等方重置 HttpClient 连接:套接字写入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 httpclient 4.4 发送 get 和 post 请求.我刚刚创建了一个简单的 httpclient 包装器以方便使用:

包 com.u8.server.sdk;导入 com.sun.net.httpserver.Headers;导入 com.u8.server.log.Log;导入 org.apache.http.Header;导入 org.apache.http.HttpEntity;导入 org.apache.http.HttpResponse;导入 org.apache.http.NameValuePair;导入 org.apache.http.client.ClientProtocolException;导入 org.apache.http.client.HttpClient;导入 org.apache.http.client.HttpRequestRetryHandler;导入 org.apache.http.client.ResponseHandler;导入 org.apache.http.client.config.RequestConfig;导入 org.apache.http.client.entity.UrlEncodedFormEntity;导入 org.apache.http.client.methods.HttpGet;导入 org.apache.http.client.methods.HttpPost;导入 org.apache.http.config.Registry;导入 org.apache.http.config.RegistryBuilder;导入 org.apache.http.conn.socket.ConnectionSocketFactory;导入 org.apache.http.conn.socket.PlainConnectionSocketFactory;导入 org.apache.http.conn.ssl.NoopH​​ostnameVerifier;导入 org.apache.http.conn.ssl.SSLConnectionSocketFactory;导入 org.apache.http.conn.ssl.TrustStrategy;导入 org.apache.http.entity.ByteArrayEntity;导入 org.apache.http.impl.client.BasicCookieStore;导入 org.apache.http.impl.client.CloseableHttpClient;导入 org.apache.http.impl.client.HttpClientBuilder;导入 org.apache.http.impl.client.HttpClients;导入 org.apache.http.impl.conn.PoolingHttpClientConnectionManager;导入 org.apache.http.impl.cookie.BasicClientCookie;导入 org.apache.http.message.BasicHeader;导入 org.apache.http.message.BasicNameValuePair;导入 org.apache.http.protocol.HttpContext;导入 org.apache.http.ssl.SSLContextBuilder;导入 org.apache.http.util.EntityUtils;导入 org.springframework.util.StringUtils;导入 javax.net.ssl.HostnameVerifier;导入 javax.net.ssl.SSLContext;导入 java.io.IOException;导入 java.io.UnsupportedEncodingException;导入 java.net.CookiePolicy;导入 java.net.URLEncoder;导入 java.nio.charset.Charset;导入 java.security.cert.CertificateException;导入 java.security.cert.X509Certificate;导入 java.util.ArrayList;导入 java.util.Iterator;导入 java.util.List;导入 java.util.Map;/*** 由 ant 于 2015 年 10 月 12 日创建.*/公共类 UHttpAgent {私人 int connectTimeout = 5000;//5s私有 int socketTimeout = 5000;//5s私人 int maxTotalConnections = 200;私有静态 UHttpAgent 实例;私有 CloseableHttpClient httpClient;私有 UHttpAgent(){}公共静态 UHttpAgent getInstance(){如果(实例 == 空){实例 = 新的 UHttpAgent();}返回实例;}公共静态 UHttpAgent newInstance(){返回新的 UHttpAgent();}公共字符串获取(字符串网址,地图参数){返回 get(url, null, params, "UTF-8");}公共字符串帖子(字符串网址,地图参数){返回帖子(网址,空,参数,UTF-8");}public String get(String url , Map headers, Map params, String encoding){if(this.httpClient == null){在里面();}字符串 fullUrl = url;String urlParams = parseGetParams(params, encoding);如果(urlParams != null){如果(网址.包含(?")){fullUrl = url + "&" + urlParams;}别的{fullUrl = url + "?"+ urlParams;}}Log.d("完整的url是"+ fullUrl);HttpGet getReq = new HttpGet(fullUrl.trim());getReq.setHeaders(parseHeaders(headers));ResponseHandler responseHandler = new ResponseHandler() {@覆盖公共字符串 handleResponse(HttpResponse httpResponse) 抛出 IOException {HttpEntity entity = httpResponse.getEntity();返回实体 != null ?EntityUtils.toString(entity) : null;}};尝试 {String res = httpClient.execute(getReq, responseHandler);返回资源;} 捕获(异常 e){e.printStackTrace();}最后 {getReq.releaseConnection();}返回空;}public String post(String url, Map headers, Map params, String encoding){列表对 = new ArrayList();如果(参数!= null){for(字符串键:params.keySet()){pair.add(new BasicNameValuePair(key, params.get(key)));}}return post(url, headers, new UrlEncodedFormEntity(pairs, Charset.forName(encoding)));}public String post(String url, Map headers, HttpEntity entity){if(this.httpClient == null) {在里面();}HttpPost httpPost = new HttpPost(url);httpPost.setHeaders(parseHeaders(headers));httpPost.setEntity(实体);ResponseHandler responseHandler = new ResponseHandler() {@覆盖公共字符串 handleResponse(HttpResponse httpResponse) 抛出 IOException {HttpEntity entity = httpResponse.getEntity();返回实体 != null ?EntityUtils.toString(entity) : null;}};尝试 {String body = httpClient.execute(httpPost, responseHandler);返回身体;} catch (IOException e) {e.printStackTrace();}最后 {httpPost.releaseConnection();}返回空;}私有头[] parseHeaders(地图头){if(null == headers || headers.isEmpty()){返回 getDefaultHeaders();}Header[] hs = new BasicHeader[headers.size()];int i = 0;for(字符串键:headers.keySet()){hs[i] = new BasicHeader(key, headers.get(key));我++;}返回 hs;}私有头[] getDefaultHeaders(){Header[] hs = new BasicHeader[2];hs[0] = new BasicHeader("Content-Type", "application/x-www-form-urlencoded");hs[1] = new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");返回 hs;}私有字符串parseGetParams(地图数据,字符串编码){if(data == null || data.size() keyItor = data.keySet().iterator();而(keyItor.hasNext()){String key = keyItor.next();String val = data.get(key);尝试 {result.append(key).append("=").append(URLEncoder.encode(val, encoding).replace("+", "%2B")).append("&");} catch (UnsupportedEncodingException e) {e.printStackTrace();}}返回 result.deleteCharAt(result.length() - 1).toString();}私有无效初始化(){RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout).setSocketTimeout(socketTimeout).setExpectContinueEnabled(true).setAuthenticationEnabled(真).建造();HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {@覆盖公共布尔重试请求(IOException e,int retryNum,HttpContext httpContext){if(retryNum >= 3){返回假;}if(e instanceof org.apache.http.NoHttpResponseException||org.apache.http.client.ClientProtocolException 的实例||e instanceof java.net.SocketException){返回真;}返回假;}};尝试{SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {@覆盖public boolean isTrusted(X509Certificate[] chain, String authType) 抛出 CertificateException {返回真;}}).建造();HostnameVerifier hostnameVerifier = NoopH​​ostnameVerifier.INSTANCE;SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);注册表 socketFactoryRegistry = RegistryBuilder.create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslFactory).建造();PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager(socketFactoryRegistry);connMgr.setMaxTotal(maxTotalConnections);connMgr.setDefaultMaxPerRoute((connMgr.getMaxTotal()));HttpClientBuilder 构建器 = HttpClients.custom().setDefaultRequestConfig(requestConfig).setSslcontext(sslContext).setConnectionManager(connMgr).setRetryHandler(retryHandler);this.httpClient = builder.build();}catch(异常 e){e.printStackTrace();}}公共 HttpClient getHttpClient(){返回 this.httpClient;}公共无效销毁(){if(this.httpClient != null){尝试{this.httpClient.close();this.httpClient = null;}catch(异常 e){e.printStackTrace();}}}}

当我使用这个类发送 post 请求时.奇怪的事情发生了:

第一次,我向服务器发送一个post请求,没问题一分钟后,我向服务器发送了相同的请求,也没关系.但几分钟后,我发送了相同的请求,出错了:

java.net.SocketException:连接被对等重置:套接字写入错误在 java.net.SocketOutputStream.socketWrite0(本机方法)在 java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)在 java.net.SocketOutputStream.write(SocketOutputStream.java:136)在 org.apache.http.impl.conn.LoggingOutputStream.write(LoggingOutputStream.java:77)在 org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:126)在 org.apache.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:138)在 org.apache.http.impl.io.SessionOutputBufferImpl.flush(SessionOutputBufferImpl.java:146)在 org.apache.http.impl.BHttpConnectionBase.doFlush(BHttpConnectionBase.java:175)在 org.apache.http.impl.DefaultBHttpClientConnection.flush(DefaultBHttpClientConnection.java:185)在 org.apache.http.impl.conn.CPoolProxy.flush(CPoolProxy.java:177)在 org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:215)在 org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:122)在 org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)在 org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)在 org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)在 org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)在 org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)在 com.u8.server.sdk.UHttpAgent.post(UHttpAgent.java:259)在 com.u8.server.sdk.UHttpAgent.post(UHttpAgent.java:147)在 com.u8.server.sdk.baidu.BaiduSDK.verify(BaiduSDK.java:30)在 com.u8.server.web.UserAction.getLoginToken(UserAction.java:100)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在 java.lang.reflect.Method.invoke(Method.java:597)

但是,我还是向服务器发送了相同的请求,又没问题了.

我每次按照上面的步骤尝试,都发生了同样的事情.

谁能帮帮我?非常感谢.

解决方案

客户端的对等点是服务器.所以对等连接重置"意味着服务器重置套接字.重置意味着强行关闭.

这可能是因为服务器中的错误.如果您还编写了服务器或 servlet(如自定义协议的情况),则需要检查服务器的行为以检查其原因.服务器的日志文件可能会提供线索.

如果服务器具有防止恶意客户端或恶意客户端的保护,则服务器可能已重置套接字,因为它已将您的客户端归类为行为不端.如果您实现了客户端协议代码,那可能是因为您的协议实现中存在错误.如果您使用第三方代码来处理通信协议,您可能仍然在滥用它;例如通过发送过大的请求.HTTP 服务器通过对标头字段和正文施加最大长度来保护自己免受拒绝服务攻击,并要求客户端以合理快的速度发送数据(无需长时间暂停),这种情况并不少见.您的客户可能违反了这些保护措施.

I used httpclient 4.4 to send get and post request. and i just created a simpile wrapper of httpclient for easy use:


    package com.u8.server.sdk;

    import com.sun.net.httpserver.Headers;
    import com.u8.server.log.Log;
    import org.apache.http.Header;
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.ClientProtocolException;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.HttpRequestRetryHandler;
    import org.apache.http.client.ResponseHandler;
    import org.apache.http.client.config.RequestConfig;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.config.Registry;
    import org.apache.http.config.RegistryBuilder;
    import org.apache.http.conn.socket.ConnectionSocketFactory;
    import org.apache.http.conn.socket.PlainConnectionSocketFactory;
    import org.apache.http.conn.ssl.NoopHostnameVerifier;
    import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
    import org.apache.http.conn.ssl.TrustStrategy;
    import org.apache.http.entity.ByteArrayEntity;
    import org.apache.http.impl.client.BasicCookieStore;
    import org.apache.http.impl.client.CloseableHttpClient;
    import org.apache.http.impl.client.HttpClientBuilder;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
    import org.apache.http.impl.cookie.BasicClientCookie;
    import org.apache.http.message.BasicHeader;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.protocol.HttpContext;
    import org.apache.http.ssl.SSLContextBuilder;
    import org.apache.http.util.EntityUtils;
    import org.springframework.util.StringUtils;

    import javax.net.ssl.HostnameVerifier;
    import javax.net.ssl.SSLContext;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.net.CookiePolicy;
    import java.net.URLEncoder;
    import java.nio.charset.Charset;
    import java.security.cert.CertificateException;
    import java.security.cert.X509Certificate;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;

    /**
     * Created by ant on 2015/10/12.
     */
    public class UHttpAgent {

        private int connectTimeout = 5000;  //5s
        private int socketTimeout = 5000;   //5s
        private int maxTotalConnections = 200;

        private static UHttpAgent instance;

        private CloseableHttpClient httpClient;

        private UHttpAgent(){

        }

        public static UHttpAgent getInstance(){
            if(instance == null){
                instance = new UHttpAgent();

            }
            return instance;
        }

        public static UHttpAgent newInstance(){
            return new UHttpAgent();
        }


        public String get(String url, Map params){

            return get(url, null, params, "UTF-8");
        }


        public String post(String url, Map params){

            return post(url, null, params, "UTF-8");
        }


        public String get(String url , Map headers, Map params, String encoding){

            if(this.httpClient == null){
                init();
            }

            String fullUrl = url;
            String urlParams = parseGetParams(params, encoding);

            if (urlParams != null)
            {
                if (url.contains("?"))
                {
                    fullUrl = url + "&" + urlParams;
                }
                else
                {
                    fullUrl = url + "?" + urlParams;
                }
            }

            Log.d("the full url is "+ fullUrl);
            HttpGet getReq = new HttpGet(fullUrl.trim());
            getReq.setHeaders(parseHeaders(headers));
            ResponseHandler responseHandler = new ResponseHandler() {
                @Override
                public String handleResponse(HttpResponse httpResponse) throws IOException {
                    HttpEntity entity = httpResponse.getEntity();
                    return entity != null ? EntityUtils.toString(entity) : null;
                }
            };

            try {

                String res = httpClient.execute(getReq, responseHandler);

                return res;

            } catch (Exception e) {
                e.printStackTrace();
            }finally {
                getReq.releaseConnection();
            }

            return null;
        }


        public String post(String url, Map headers, Map params, String encoding){

            List pairs = new ArrayList();
            if(params != null){

                for(String key : params.keySet()){
                    pairs.add(new BasicNameValuePair(key, params.get(key)));
                }
            }

            return post(url, headers, new UrlEncodedFormEntity(pairs, Charset.forName(encoding)));
        }


        public String post(String url, Map headers, HttpEntity entity){

            if(this.httpClient == null) {
                init();
            }

            HttpPost httpPost = new HttpPost(url);
            httpPost.setHeaders(parseHeaders(headers));
            httpPost.setEntity(entity);

            ResponseHandler responseHandler = new ResponseHandler() {
                @Override
                public String handleResponse(HttpResponse httpResponse) throws IOException {
                    HttpEntity entity = httpResponse.getEntity();
                    return entity != null ? EntityUtils.toString(entity) : null;
                }
            };

            try {


                String body = httpClient.execute(httpPost, responseHandler);

                return body;

            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                httpPost.releaseConnection();
            }

            return null;

        }


        private Header[] parseHeaders(Map headers){
            if(null == headers || headers.isEmpty()){
                return getDefaultHeaders();
            }

            Header[] hs = new BasicHeader[headers.size()];
            int i = 0;
            for(String key : headers.keySet()){
                hs[i] = new BasicHeader(key, headers.get(key));
                i++;
            }

            return hs;
        }


        private Header[] getDefaultHeaders(){
            Header[] hs = new BasicHeader[2];
            hs[0] = new BasicHeader("Content-Type", "application/x-www-form-urlencoded");
            hs[1] = new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");
            return hs;
        }


        private String parseGetParams(Map data, String encoding){
            if(data == null || data.size()  keyItor = data.keySet().iterator();
            while(keyItor.hasNext()){
                String key = keyItor.next();
                String val = data.get(key);

                try {
                    result.append(key).append("=").append(URLEncoder.encode(val, encoding).replace("+", "%2B")).append("&");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }

            return result.deleteCharAt(result.length() - 1).toString();

        }


        private void init(){

            RequestConfig requestConfig = RequestConfig.custom()
                    .setConnectTimeout(connectTimeout)
                    .setSocketTimeout(socketTimeout)
                    .setExpectContinueEnabled(true)
                    .setAuthenticationEnabled(true)
                    .build();

            HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
                @Override
                public boolean retryRequest(IOException e, int retryNum, HttpContext httpContext) {

                    if(retryNum >= 3){
                        return false;
                    }


                    if(e instanceof org.apache.http.NoHttpResponseException
                            || e instanceof org.apache.http.client.ClientProtocolException
                            || e instanceof java.net.SocketException){

                        return true;
                    }

                    return false;
                }
            };


            try{

                SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {

                    @Override
                    public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                        return true;
                    }
                }).build();

                HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
                SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);

                Registry socketFactoryRegistry = RegistryBuilder.create()
                        .register("http", PlainConnectionSocketFactory.getSocketFactory())
                        .register("https", sslFactory)
                        .build();

                PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager( socketFactoryRegistry);
                connMgr.setMaxTotal(maxTotalConnections);
                connMgr.setDefaultMaxPerRoute((connMgr.getMaxTotal()));

                HttpClientBuilder builder = HttpClients.custom()
                        .setDefaultRequestConfig(requestConfig)
                        .setSslcontext(sslContext)
                        .setConnectionManager(connMgr)
                        .setRetryHandler(retryHandler);

                this.httpClient = builder.build();


            }catch (Exception e){
                e.printStackTrace();
            }

        }

        public HttpClient getHttpClient(){

            return this.httpClient;
        }

        public void destroy(){

            if(this.httpClient != null){
                try{
                    this.httpClient.close();
                    this.httpClient = null;
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
        }


    }

when I use this class to send post request. something strange happened:

the first time, I send a post request to the server, it's okafter a minutes, I send a same request to the server, it's ok too.but after a few minutes, I send a same request, something wrong:


    java.net.SocketException: Connection reset by peer: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at org.apache.http.impl.conn.LoggingOutputStream.write(LoggingOutputStream.java:77)
        at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:126)
        at org.apache.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:138)
        at org.apache.http.impl.io.SessionOutputBufferImpl.flush(SessionOutputBufferImpl.java:146)
        at org.apache.http.impl.BHttpConnectionBase.doFlush(BHttpConnectionBase.java:175)
        at org.apache.http.impl.DefaultBHttpClientConnection.flush(DefaultBHttpClientConnection.java:185)
        at org.apache.http.impl.conn.CPoolProxy.flush(CPoolProxy.java:177)
        at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:215)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:122)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
        at com.u8.server.sdk.UHttpAgent.post(UHttpAgent.java:259)
        at com.u8.server.sdk.UHttpAgent.post(UHttpAgent.java:147)
        at com.u8.server.sdk.baidu.BaiduSDK.verify(BaiduSDK.java:30)
        at com.u8.server.web.UserAction.getLoginToken(UserAction.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

but then , I still send a same request to the server, it's ok again.

Every time I tried according to the above steps, The same thing happened.

Anyone can help me ? Thanks a lot.

解决方案

The peer of your client is the server. So "Connection reset by peer" means the server reset the socket. Reset means forceably closed.

This might be because of a bug in the server. If you also wrote the server or servlet (as will be the case for a custom protocol), you need to examine the behaviour of the server to examine the cause of this. The log files of the server might provide clues.

If the server has protection against bisbehaving or malicious clients, the server might have reset the socket because it has classified your client as misbehaving. If you implemented the client protocol code it might be because of a bug in your protocol implementation. If you are using third party code for handling the communication protocol you might still be misusing it; for example by sending excessively large requests. It is not uncommon for HTTP servers to protect themselves against denial of service attacks by imposing maximum lengths for header fields and bodies, and to require that clients send data at a reasonably fast rate (without pausing for long periods). Your client might have fallen foul of these protections.

这篇关于对等方重置 HttpClient 连接:套接字写入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 21:49