[AC-3721] TiHTTPClient java.lang.NullPointerException
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2016-06-12T05:02:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Andrea |
Assignee | Shak Hossain |
Created | 2016-06-02T20:16:06.000+0000 |
Updated | 2016-06-13T02:07:13.000+0000 |
Description
I'm using method Ti.Network.createHTTPClient in order to call a php service passing post variables.
I get a java.lang.NullPointerException
[ERROR] : TiHTTPClient: (TiHttpClient-2) [732,732] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [ERROR] : TiHTTPClient: java.lang.NullPointerException [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:783) [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347) [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296) [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:143) [ERROR] : TiHTTPClient: at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:544) [ERROR] : TiHTTPClient: at java.net.URLConnection.getContentLength(URLConnection.java:316) [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:159) [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:85) [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1207) [ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:841)
var client = Ti.Network.createHTTPClient({ // function called when the response data is available onload : function(e) { Ti.API.info("Received text: " + this.responseText); alert('success'); }, // function called when an error occurs, including a timeout onerror : function(e) { Ti.API.debug(e.error); alert('error'); }, timeout : 5000 // in milliseconds }); // Prepare the connection. //client.open("POST", url); client.open("POST", url); client.send({ "type" : "getcategories", "sourcetype" : "source_app", });
Of course if I call the php file from my browser I get the http response without any problem
Testing this with:
I do not find any issues. Could it be that your server expects something in the headers which causes it to give a wrong response?
Hello, I can reconfirm that the issue is not occurring with Ashraf Abu's code. Can you follow his guide, or provide more info? Regards, Sharif.
I re-installed Titanium sdk, and everything is ok now, tsk
That's good to hear. Let us know if this reproduces again some how.