【问题标题】:Every few calls to webservice I get: com.android.volley.NoConnectionError: java.io.IOException: Hostname was not verified每隔几次调用 web 服务我得到:com.android.volley.NoConnectionError: java.io.IOException: Hostname was not verify
【发布时间】:2014-10-17 17:45:46
【问题描述】:

每隔几次调用 web 服务我都会收到一个错误:com.android.volley.NoConnectionError: java.io.IOException: Hostname was not verify

仅在应用程序设置中执行“强制关闭”有助于让我的应用程序再次从 web 服务获取结果。

这是一个带有有效证书的 ssl 连接(在 iOS 上一切正常)。

我在 android 4.1.2、4.4.4 和模拟器上检查了这个。 Volley 图书馆有什么问题吗?我应该在哪里搜索以获取更多信息以解决问题。

我看到有类似的问题,但答案说要删除验证:/

@Override
protected Boolean doInBackground(Object... arg0) {

    // Instantiate the cache
    Cache cache = new DiskBasedCache(ctx.getCacheDir(), 1024 * 1024 * 10); // 10MB cap

    // Set up the network to use HttpURLConnection as the HTTP client.
    Network network = new BasicNetwork(new HurlStack());

    // Instantiate the RequestQueue with the cache and network.
    queue = new RequestQueue(cache, network);
    queue.start();

    future = RequestFuture.newFuture();

    Gson gson = new Gson();
    String jsonString = gson.toJson(generalAsk);
    JSONObject js = null;

    try {
        js = new JSONObject(jsonString);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    jsObjRequest = new JsonObjectRequest(Request.Method.POST, WsUtils.WS_URL + wsAddress, js, future, future);

    queue.add(jsObjRequest);

    try {
        JSONObject response = future.get();

        Gson gs = new GsonBuilder().serializeNulls().create();
        generalResponse = (BaseResponse) gs.fromJson(response.toString(), c);
        return true;

    } catch (InterruptedException e) {
        errorMessage = e.getMessage();
    } catch (ExecutionException e) {
        errorMessage = e.getMessage();
    }
    return false;
}

【问题讨论】:

  • 尝试在代码的不同位置添加延迟,有时时间戳等差异会导致错误,它可能有助于调试。

标签: android android-volley


【解决方案1】:

原来是服务器端有问题。经过管理员几个小时的挖掘,一切正常。不幸的是,我不知道它们发生了什么变化,但肯定不是 Android 的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-27
    • 1970-01-01
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    相关资源
    最近更新 更多