【问题标题】:Titanium appcelerator createHTTPClient() not working Android 5.0 LollipopTitanium appcelerator createHTTPClient() 不工作 Android 5.0 Lollipop
【发布时间】:2015-05-21 21:04:00
【问题描述】:

我在 Titan 中发出了一个简单的 GET 请求,似乎在 android 5.0 及更高版本中无法正常工作。这是我收到的控制台的响应。

[INFO]:状态:200,连接类型:GET

=> 安卓 5.0

{"source":{"password":null,"status":0,"username":null,"autoRedirect":true,"bubbleParent":true,"allResponseHeaders":"","location": "","autoEncodeUrl":true,"apiName":"Ti.Network.HTTPClient","re​​sponseXML":null,"validatesSecureCertificate":false,"readyState":1,"domain":null,"responseText":" ","re​​sponseData":null,"connectionType":"GET","statusText":null,"connected":false,"_events":{"disposehandle":{}}},"error":"握手 失败","代码":-1,"成功":false}

错误:“握手失败

这是我使用的代码。

var url = "MY URL";

        var loader = Titanium.Network.createHTTPClient();

        loader.onload = function() 
        {
            Titanium.API.info('Status: ' + this.status);
            Titanium.API.info('ResponseText: ' + this.responseText);
            Titanium.API.info('connectionType: ' + this.connectionType);
            Titanium.API.info('location: ' + this.location);
        };

        loader.onerror = function (e) {
          console.log(JSON.stringify(e));
          console.log("ERROR: " + JSON.stringify(e.error));
        };

        loader.open("GET",url);
        loader.send();

希望你能帮我解决这个问题。

【问题讨论】:

  • 如果您使用的是 https:// url,该请求似乎在 Android 5.0 及更高版本中不起作用。我所做的是删除 S 并将其保留为 http,但这不是永久解决方案,因为可能存在需要 https:// 的 Web 服务

标签: android titanium appcelerator


【解决方案1】:

这是网络服务器的 SSL 证书的问题。

您可以从 Chrome 验证证书是否有效:

【讨论】:

    猜你喜欢
    • 2014-12-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-13
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多