com.android.volley.NoConnectionError:javax.net.ssl.SSLHandshakeException:握手失败

时间:2017-02-02 12:25:59

标签: android android-volley handshake sslhandshakeexception

使用volley进行基本网络操作,将项目添加为模块时不会出现连接握手错误。

虽然该模块在另一个项目中运行良好。

在R& D上,添加了重试策略,但仍然没有使用相同的错误。

这是我的代码。 https://gist.github.com/fizzysoftware/a895bc2cbd1ad9a048277859f3f23963

3 个答案:

答案 0 :(得分:1)

可能是以下两种情况之一:

  1. 您尝试连接到HTTP网址,但它实际上是一个HTTPS网址,或者
  2. 您尝试连接到HTTPS页面,但证书无效。
  3. 这至少是我到目前为止遇到的情况......

答案 1 :(得分:0)

在我的项目中也面临着同样的问题。在Marshmallow,它的工作很有意思。但在Kitkat版本中它提出了问题

" com.android.volley.NoConnectionError:javax.net.ssl.SSLHandshakeException:握手失败"

为了处理这个问题,我使用了google的auth依赖项。请在Gradle中添加以下依赖项

compile 'com.google.android.gms:play-services-auth:11.0.2'

并实施在较低版本中安装安全提供程序的方法,如果需要安装

private void updateAndroidSecurityProvider(Activity callingActivity) {
try {
    ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
    // Thrown when Google Play Services is not installed, up-to-date, or enabled
    // Show dialog to allow users to install, update, or otherwise enable Google Play services.
    GooglePlayServicesUtil.getErrorDialog(e.getConnectionStatusCode(), callingActivity, 0);
} catch (GooglePlayServicesNotAvailableException e) {
    Log.e("SecurityException", "Google Play Services not available.");
}

}

然后在进行网络操作之前​​调用活动中的方法。

答案 2 :(得分:0)

将url从Https更改为Http即可。

相关问题