org.apache.http.NoHttpResponseException: XX.XX.XX.XX:443 omis de répondre

Actuellement, je suis en utilisant Apache http composants client V4.3.5. Dans mon cas, je peux télécharger des fichier de petite taille(1 ko), mais il n'est pas de travailler sur de gros fichiers(100ko) quand je lance le code de l'exception "org.apache.http.NoHttpResponseException: 192.168.128.109:443 omis de répondre". Quelqu'un peut jeter un oeil à mon code et je voudrais savoir quelles sont les causes de mon problème?

Voici mon code:

public static void main(String[] args) throws IOException,
        KeyStoreException {
    try {
        SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(
                null, new TrustStrategy() {
                    public boolean isTrusted(X509Certificate[] chain,
                            String authType) throws CertificateException {
                        return true;
                    }
                }).build();

        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                sslContext,
                SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

        HttpClientBuilder builder = HttpClientBuilder.create();
        builder.disableContentCompression();
        builder.setSSLSocketFactory(sslsf);
        SocketConfig config = SocketConfig.custom().setSoKeepAlive(true).setSoTimeout(300000).build();
        builder.setDefaultSocketConfig(config);
        CloseableHttpClient httpclient = builder.build();

        HttpPost httppost = new HttpPost("https://192.168.128.109/upload");

        String encodedAuthorization = DatatypeConverter
                .printBase64Binary("admin:itronitr".getBytes());
        httppost.setHeader("Authorization", "Basic " + encodedAuthorization);

        FileBody bin = new FileBody(new File("c:\\test.txt"));
        String boundary = "hK1oPL5_XSfbm6lkCNlKI63rltrew5Bqik0ul";

        HttpEntity reqEntity = MultipartEntityBuilder.create()
                .setBoundary(boundary).addPart("upfile", bin).build();

        httppost.setEntity(reqEntity);

        System.out.println(httppost.getEntity().getContentLength());
        System.out
                .println(httppost.getEntity().getContentType().toString());

        CloseableHttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());

        String content = EntityUtils.toString(resEntity);
        System.out.println(content);

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

}

Grâce,
Le projet de loi

  • Nous utilisons python à télécharger le même fichier sur le serveur et il est de travail. Ce problème se produit seulement en Java. Mon JDK java version "1.7.0_67".
  • Je résoudre ce problème en remplaçant la HttpRequestRetryHandler dans le client HTTP. stackoverflow.com/questions/10570672/...
InformationsquelleAutor biao li | 2014-09-30