Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17879] Android 5.0: javax.net.ssl.SSLHandshakeException: Connection closed by peer

GitHub Issuen/a
TypeBug
PriorityHigh
StatusResolved
ResolutionHold
Resolution Date2014-11-06T17:38:54.000+0000
Affected Version/sRelease 3.4.1
Fix Version/sn/a
ComponentsAndroid
Labelslook1, parity, qe-3.4.1
ReporterEduardo Gomez
AssigneeIngo Muschenetz
Created2014-10-20T22:36:35.000+0000
Updated2017-03-24T18:25:35.000+0000

Description

Issue Description

Today now that Google released what should be the final builds of Android L we upgraded our Nexus 5 device to it from the Google Page: http://developer.android.com/preview/index.html I just loaded this in the iPhone Sim and I got the success alert as expected. I tried it on the Android Phone running 4.2.2 and it also got the success alert. On the Nexus 5 running Android 5.0 I get an error alert with this error in the logs attached.

Sample code

var url = "https_url";
var xhr = Ti.Network.createHTTPClient({
    onload: function(e) {
        Ti.API.debug(this.responseText);
        alert('success');
    },
    onerror: function(e) {
        Ti.API.debug(e.error);
        alert('error');
    },
    timeout:5000  /* in milliseconds */
});
xhr.open("GET", url);
xhr.send(); 

Logs

10-20 13:05:18.293: D/Window(27268): Checkpoint: postWindowCreated() 
10-20 13:05:18.296: E/TiHttpClient(27268): (TiHttpClient-1) [143,143] HTTP Error (javax.net.ssl.SSLHandshakeException): Connection closed by peer 
10-20 13:05:18.296: E/TiHttpClient(27268): javax.net.ssl.SSLHandshakeException: Connection closed by peer 
10-20 13:05:18.296: E/TiHttpClient(27268): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) 
10-20 13:05:18.296: E/TiHttpClient(27268): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302) 
10-20 13:05:18.296: E/TiHttpClient(27268): at com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl.java:598) 
10-20 13:05:18.296: E/TiHttpClient(27268): at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:560) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:70) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:172) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653) 
10-20 13:05:18.296: E/TiHttpClient(27268): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) 
10-20 13:05:18.296: E/TiHttpClient(27268): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1328) 
10-20 13:05:18.296: E/TiHttpClient(27268): at java.lang.Thread.run(Thread.java:818) 
10-20 13:05:18.311: D/TiAPI(27268): Connection closed by peer 

Tiapp.xml

http://docs.appcelerator.com/titanium/3.0/#!/guide/Installing_the_Android_SDK-section-29004851_InstallingtheAndroidSDK-SupportforAndroidWearandAndroidLSDKs

Comments

  1. Ingo Muschenetz 2014-10-20

    Do we have to use such a vendor-specific URL? I would imagine we could use something more generic.
  2. Ingo Muschenetz 2014-10-21

    [~egomez] I'm confused:

    So, using the above code snippet, it fails with the vmdev URL, but succeeds with another HTTPS url like link.opera.com?

    Both URLs load successfully using the Nexus 5 browser

    When you say that "It's tricky that this only fails on Android-L," I would encourage you to use either Android L or Android 5.0. They are the same thing.

  3. Travis Crist 2014-10-21

    @Ingo, {quote} So, using the above code snippet, it fails with the vmdev URL, but succeeds with another HTTPS url like link.opera.com? {quote} Yes it fails on the vmdev URL but it succeeds with other HTTPS url's like link.opera.com. I have been trying to find a generic one that fails in the same way but have not been successful. I have our internal support team looking at the server to see if there is an issue with its SSL cert or its configuration I will update this ticket with their results. On the same device running Android 4.4.4 it connects to the vmdev URL successfully but as soon as its upgraded to Android 5.0 then it starts failing. {quote} Both URLs load successfully using the Nexus 5 browser {quote} Yes, In the browser on the Nexus 5 running Android 5.0 both urls load successfully. {quote} When you say that "It's tricky that this only fails on Android-L," I would encourage you to use either Android L or Android 5.0. They are the same thing. {quote} This only occurs on Android 5.0 sorry for the confusion.
  4. Ingo Muschenetz 2014-10-21

    [~tcrist] Can you instead try this with a simple native test case? I want to confirm first then it's not an Android bug.
  5. Travis Crist 2014-10-21

    Ingo, I would be happy to try out a simple native test case but I don't have the time to develop one on my own. Can you provide a simple Android test case that I can try out? Thanks, Travis
  6. Eric Wieber 2014-10-21

    I am able to reproduce this issue with above sample code and: Device: Nexus 5, Android 5.0 Appcelerator Studio 3.4.0.201409261245 Titanium SDK 3.4.0.GA CLI 3.4.0 Android API 21 (5.0)
  7. Ingo Muschenetz 2014-10-21

    [~egomez] is the sample app a Titanium application or a native application?
  8. Eduardo Gomez 2014-10-21

    Native. Attempts to make the Http Request to the URL under test.
  9. Ingo Muschenetz 2014-10-21

    Thanks. So, if it works (natively) in 4.3, but does not work (natively) in 5.0, that would suggest to me an Android bug, no?
  10. Travis Crist 2014-10-21

    @Ingo, I think that means it could be an Android bug. There is the possibility that Google changed an Android API that you are accessing. On this page http://developer.android.com/preview/index.html they say that the new API's are finalized. The page here http://developer.android.com/sdk/api_diff/21/changes.html has the diff report of the old versus new API's. It does appear that the X509TrustManagerExtensions class had some changes made to it so maybe that new method isUserAddedCertificate needs to be used. http://developer.android.com/sdk/api_diff/21/changes.html There are also some changes to the android.net area. I could be an Android bug but I think that this system image should be very close to the final version to be released on Nov 3rd since it was uploaded by Google last Thursday so even if it is an Android bug we may have to find a workaround depending on what drops on Nov 3rd.
  11. Ingo Muschenetz 2014-10-21

    [~tcrist] and [~egomez] is it possible to get the native application working correctly, and then we can review whatever changes need to be made for the Titanium SDK? If we can't find a workaround for native, I don't know how we can fix it for Titanium.
  12. Ingo Muschenetz 2014-11-06

    Resolving as on-hold until Google responds.

JSON Source