0

My program is supposed to make multiple POST requests to a https site and I need it to do a SSL-handshake each time it does a new request. However it seems to only do the handshake the first time and then use the existing connection to do the other requests without a new handshake. I'm sure it doesn't do the handshake later times, because the first time it takes about 700 ms to do the request and receive a response, but later ones only take about 30 ms.

Here's how I initialize the client: (Am I missing some property here?)

    SSLContext context = SSLContext.getInstance("SSL");
    context.init(kms, trustAllCerts, null);
    SSLContext.setDefault(context);

    ClientConfig config = new DefaultClientConfig();
    config.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, timeout * 1000);
    config.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
    config.getFeatures().put(ClientConfig.FEATURE_DISABLE_XML_SECURITY, true);
    client = Client.create(config);

And here's how I make the actual request:

    ClientResponse cr = service.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML).post(ClientResponse.class, batch);

(The service variable is the Builder class, which creates the ClientRequest. It's where the URL is specified.)

Any ideas, please?

4

1 に答える 1

0

HTTP には永続的な接続があり、SSL には再開可能なセッションがあります。どちらも、達成しようとしていることを防ぐことを特に目的としています。

サーバーの内部を掘り下げる場合は、おそらくテスト目的で両方をオフにしますが、本番環境に展開するのに夢中になる構成をテストする意味がわかりません。

于 2012-08-23T22:48:13.383 に答える