1

非常に長いPOSTリクエスト(2時間以上)に対して次のテストコードが正常に実行されています:

        URL postURL = new URL(url);            
        con = (HttpURLConnection) postURL.openConnection();            
        con.setUseCaches(false);
        con.setDoOutput(true);
        con.setDoInput(true);
        con.setRequestMethod("POST");            
        OutputStream out = con.getOutputStream();
        OutputStreamWriter wout = new OutputStreamWriter(out, "UTF-8");
        wout.write(xmlRequest);
        wout.flush();
        out.close();
        con.connect();            
        int httpResponseCode = HttpURLConnection.HTTP_SERVER_ERROR;
        try {
            httpResponseCode = con.getResponseCode();
        } catch (IOException e) {
            log(e.toString() + " Error retrieving the status code");
        }
        log("Failure status code " + httpResponseCode + " received: ");

この投稿をあるホストから別のホストに実行すると、1つの正確なLinux Redhatホストを除いて、すべての環境で正常に実行されます。このホストからこのコードを実行すると、例外が発生しました。

java.net.SocketException:recv()が失敗しました、errno=104ピアによって接続がリセットされましたステータスコードの取得中にエラーが発生しました
失敗ステータスコード500を受信しました。

ターゲットサーバーのホストは、すべてのテストで同じホストです。したがって、違いはクライアントの呼び出し元ホストのみにあります。

したがって、このLinuxマシンの正確なtcp設定が、正確に2時間後に受信に失敗する原因を理解しようとしています。

私は、送信ポストのそのような「誤った」使用と応答を2時間以上待つことについて、ここで責任を負うことに同意します;)しかし、質問はこれを引き起こしているものです

4

2 に答える 2

0

google for 7200 seconds tcp redhat など

   tcp_keepalive_time (integer; default: 7200; since Linux 2.2)
          The number of seconds a connection needs to be idle  before  TCP
          begins sending out keep-alive probes.  Keep-alives are only sent
          when the SO_KEEPALIVE socket option  is  enabled.   The  default
          value  is  7200 seconds (2 hours).  An idle connection is termi-
          nated after approximately an additional 11 minutes (9 probes  an
          interval of 75 seconds apart) when keep-alive is enabled.

          Note that underlying connection tracking mechanisms and applica-
          tion timeouts may be much shorter.
于 2012-06-24T19:37:40.620 に答える