Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Performance problems with HTTPS

  1. #1
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default Performance problems with HTTPS

    Has anyone used the Spring Android Rest Template over https?

    We've recently integrated this into our android application and are running into performance problems when we switch our REST urls to HTTPS.

    Everything works fine under HTTP. Response times from the server are around a second to invoke the REST template and deserialize our JSON object. However, when we switch over to HTTPS it's taking 10-20 seconds to get complete the request.

    Anyone else have this problem?

    Thanks,

    Charles

  2. #2

    Default Re: Performance problems with HTTPS

    How are you connecting? Are you using RestTemplate.exchange with an HTTPS URI or some other mechanism?

  3. #3
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Slow:

    Code:
    template.getForObject("https://myserver/foo", Foo.class);
    Fast:

    Code:
    template.getForObject("http://myserver/foo", Foo.class);
    The difference is an order of magnitude (e.g. 500ms cf 5000-10000ms).
    Last edited by chudak; Mar 18th, 2011 at 12:39 PM. Reason: fix method names

  4. #4

    Default Re: Performance problems with HTTPS

    Hmmmmm ....

    I seem to be getting a:

    Code:
    org.springframework.web.client.ResourceAccessException: I/O error: No peer certificate; nested exception is javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
    when I try something similar, however, I am using the exchange method because I want access to the HTTP headers rather than your getForObject:

    Code:
    ResponseEntity responseEntity = restTemplate.exchange("https://myserver/foo", 
    				    	                                     HttpMethod.GET, 
    					                                     new HttpEntity<String(headers), 
    					                                     null);

  5. #5
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    The above url was just an example...that's not my actual server url.

  6. #6

    Default Re: Performance problems with HTTPS

    Yes, I know. I was actually using an internal Tomcat server to connect to. Like you, I was using "https://myserver/foo" as a stand-in for the real URL.

  7. #7
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default Problem solved, kind of

    I think this has something to do with the hostname verification being done by the http components library. With my cert it appears very slow.

    Changing my template to use the default JSSE facilities made a HUGE difference (and I verified this earlier by trying to hit the same secured and insecured urls using URL.openConnection().

    Code:
    org.springframework.web.client.RestTemplate template = new org.springframework.web.client.RestTemplate();
    template.setRequestFactory(new org.springframework.http.client.SimpleClientHttpRequestFactory());

  8. #8
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Now I'm getting intermittent failures like the following:

    Code:
    Caused by: java.lang.IllegalArgumentException: No matching constant for [-1]
    at org.springframework.http.HttpStatus.valueOf(HttpStatus.java:369)
    at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:47)
    at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:45)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:442)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:404)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:202)
    The invocation will work then it will throw this error.

  9. #9

    Default секреты игры &

    Интересно написано

  10. #10
    Join Date
    Nov 2010
    Posts
    175

    Default

    @chudak and @dutchman_mn, I've opened a new JIRA for this issue. I'm assuming you were both using the M2 build. If not, please let me know. Thanks!

    https://jira.springsource.org/browse/ANDROID-31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •