[TIMOB-25533] Android: Allow HTTPClient to send request in onload
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-23T17:53:20.000+0000 |
Affected Version/s | Release 7.1.0 |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | TiHTTPClient, android, java, java.net.SocketTimeoutException |
Reporter | knd_rt@hotmail.com |
Assignee | Gary Mathews |
Created | 2017-10-30T01:32:58.000+0000 |
Updated | 2018-10-25T14:01:21.000+0000 |
Description
I got an app that send post json objects synchronous via recursive function,
Once an object is sent I wait for the response before sending another, but Im getting timedout errors:
[INFO] to server: {"params":{"venta":{"ven_fecha":"2017-10-29 19:15:57","ven_usuario":7,"ven_cliente":279,"ven_salida":71,"ven_ruta":1,"ven_localidad":1,"ven_total":316,"ven_pagado":316,"ven_factura":0,"ven_tipo":1,"ven_estatus":0,"apa_monto":0,"ven_descuento":"","Detalles":[{"vpr_venta":3,"vpr_salida":71,"vpr_producto":77,"vpr_precio_oficial":121,"vpr_precio_venta":121,"vpr_IVA":0,"vpr_hectolitros":0,"vpr_cantidad":1,"vpr_devolucion":0,"vpr_estatus":0,"vpr_importe":121,"vpr_descripcion":"BONAFONT 24/600ML","vpr_costo":82.42},{"vpr_venta":3,"vpr_salida":71,"vpr_producto":79,"vpr_precio_oficial":88,"vpr_precio_venta":88,"vpr_IVA":0,"vpr_hectolitros":0,"vpr_cantidad":1,"vpr_devolucion":0,"vpr_estatus":0,"vpr_importe":88,"vpr_descripcion":"BONAFONT 12/1LT","vpr_costo":59.04},{"vpr_venta":3,"vpr_salida":71,"vpr_producto":80,"vpr_precio_oficial":107,"vpr_precio_venta":107,"vpr_IVA":0,"vpr_hectolitros":0,"vpr_cantidad":1,"vpr_devolucion":0,"vpr_estatus":0,"vpr_importe":107,"vpr_descripcion":"BONAFONT 12/1.5 LTS","vpr_costo":71.96}]},"usuario":"marcelo","clave":"m1"},"metodo":"subirVentas","url":"http://bebimex.com/sw/servidor/mobil.php"}
[INFO] art: Background partial concurrent mark sweep GC freed 115194(6MB) AllocSpace objects, 67(1340KB) LOS objects, 40%% free, 14MB/23MB, paused 563us total 109.330ms
[ERROR] TiHTTPClient: (TiHttpClient-7) [11182,220758] HTTP Error (java.net.SocketTimeoutException): timeout
[ERROR] TiHTTPClient: java.net.SocketTimeoutException: timeout
[ERROR] TiHTTPClient: at com.android.okhttp.okio.Okio$3.newTimeoutException(Okio.java:212)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.AsyncTimeout.exit(AsyncTimeout.java:261)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:907)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:783)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
[ERROR] TiHTTPClient: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:521)
[ERROR] TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1224)
[ERROR] TiHTTPClient: at java.lang.Thread.run(Thread.java:761)
[ERROR] TiHTTPClient: Caused by: java.net.SocketException: Socket operation on non-socket
[ERROR] TiHTTPClient: at java.net.SocketInputStream.socketRead0(Native Method)
[ERROR] TiHTTPClient: at java.net.SocketInputStream.read(SocketInputStream.java:151)
[ERROR] TiHTTPClient: at java.net.SocketInputStream.read(SocketInputStream.java:120)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.Okio$2.read(Okio.java:136)
[ERROR] TiHTTPClient: at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
[ERROR] TiHTTPClient: ... 12 more
[INFO] status 0
Attachments
File | Date | Size |
---|---|---|
app.tar.gz | 2017-11-16T05:46:49.000+0000 | 9297776 |
Hello [~knd_rt@hotmail.com], Thanks for sharing with us. Can you please provide a sample test case to reproduce this issue on our end?
Hello [~knd_rt@hotmail.com], Just passing a followup here.Are you able to get that sorted out? Please let us know if you need more help with this issue. Regards Axway Appcelerator Support
This is actually the method I export to handle all post request, In some cases it works perfect but sometimes some request just get in the limbo. This file is in my lib folder and required in my controllers via: var http = require('http.js'); and used like this:
Hello [~knd_rt@hotmail.com], We are unable to reproduce the issue on HUAWEI GR3 2017 device using the latest SDK 6.3.0.GA Please create a full test project and test steps to test the issue. Thanks
Hello [~knd_rt@hotmail.com], Please get back to us with a full reproducible sample code and guide to follow to reproduce the issue in our environment. Thanks.
It is complicated to generate since theres is a lot of details, the server is php and is using ZEND as json parser(encode / decode). I run with -l trace and got this:
why is this happening?:
Hello [~knd_rt@hotmail.com], We are investigating this.Can you please test this on latest SDK and let us know the results. Thanks
I created a test project using latest SDK with JSON data I need to upload to server, I tested and got same errors:
Hello, I have tested the issue and unable to reproduce the issue using SDK 6.3.0.GA. Please check the callback function used in the *http.js* file(onload function) and make sure there is no syntax error. Please share your appc info here. *Test Environment:* Appcelerator Command-Line Interface, version 6.3.0 Mac OS X 10.12.6 Architecture 64bit CPUs 4 Memory 8589934592 Axway Appcelerator Studio, build: 4.10.0.201709271713 Appcelerator Command-Line Interface, version 6.2.4, SDK Version = SDK 6.3.0.GA Node.js Version = 4.7.0 npm Version = 2.15.11 Android Device: HUAWEI GR3 2017 *Test Steps:* 1. Open Studio 2. Run the project using the sample code provided 3. Click the label *send http post json* and no http error found on our end *Output:* Console logs:
Best
I checked the server and something is not right, the sample proyect should send 4 json objects, and only 2 got inserted, :
Also it is supposed to only send one json and wait for the response before sending another, and your log shows async sent. APPC INFO: Operating System Name = Manjaro Linux Version = 17.0.6-EOL Architecture = 64bit # CPUs = 2 Memory = 7.6GB Node.js Node.js Version = 6.11.5 npm Version = 5.5.1 Appcelerator CLI Installer = 4.2.9 Core Package = 6.3.0 Titanium CLI CLI Version = 5.0.14 node-appc Version = 0.2.41 Titanium SDKs 6.3.0.GA Version = 6.3.0 Install Location = /home/knd/.titanium/mobilesdk/linux/6.3.0.GA Platforms = android, mobileweb node-appc Version = 0.2.43 6.2.2.GA Version = 6.2.2 Install Location = /home/knd/.titanium/mobilesdk/linux/6.2.2.GA Platforms = android, mobileweb node-appc Version = 0.2.43 6.1.2.GA Version = 6.1.2 Install Location = /home/knd/.titanium/mobilesdk/linux/6.1.2.GA Platforms = android, mobileweb node-appc Version = 0.2.43 6.1.0.GA Version = 6.1.0 Install Location = /home/knd/.titanium/mobilesdk/linux/6.1.0.GA Platforms = android, mobileweb node-appc Version = 0.2.43 Java Development Kit Version = 1.8.0_152 Java Home = /lib/jvm/java-8-jdk
master: https://github.com/appcelerator/titanium_mobile/pull/9893
I used jquery .ajax in a webview as a workaround to send the json objects
FR Passed. Waiting for merge to get enabled.
PR Merged.
*Closing ticket* Verified fix in SDK Version
7.5.0.v20181025051112
. test and other information can be fount at: https://github.com/appcelerator/titanium_mobile/pull/9893