【问题标题】:com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failedcom.android.volley.NoConnectionError:javax.net.ssl.SSLHandshakeException:握手失败
【发布时间】:2017-06-19 12:38:33
【问题描述】:

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

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

在研发上,添加了重试策略,但仍然出现同样的错误。

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

【问题讨论】:

    标签: android android-volley handshake sslhandshakeexception


    【解决方案1】:

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

    1. 您尝试连接到一个 HTTP url,但它实际上是一个 HTTPS url,或者
    2. 您尝试连接到 HTTPS 页面,但证书无效。

    这些至少是我迄今为止遇到的情况......

    【讨论】:

    • 不,实际上该 url 只是 https,它在 marshmallow 版本中运行良好,但在 kitkat 中没有。
    • 您能否发布一些代码,以便我们了解您如何尝试调用它。请和 logcat :)
    • 请看我编辑的问题。我收到消息 com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed 的 Volley 服务器错误
    • https 改为 http 时得到响应
    • 谢谢。我在 http url 中使用了 https。现在问题解决了
    【解决方案2】:

    在我的项目中也面临同样的问题。在 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.");
    }
    

    }

    然后在您的活动中调用该方法,然后再进行网络操作。

    【讨论】:

      【解决方案3】:

      将 url 从 Https 更改为 Http 即可。

      【讨论】:

      • 删除 http://www.部分来自 URL。
      猜你喜欢
      • 2018-07-28
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多