You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Mauricio Ramirez (JIRA)" <ji...@apache.org> on 2017/11/19 17:48:00 UTC

[jira] [Created] (CB-13591) File sending fails on first try and succeds on retry.

Mauricio Ramirez created CB-13591:
-------------------------------------

             Summary: File sending fails on first try and succeds on retry.
                 Key: CB-13591
                 URL: https://issues.apache.org/jira/browse/CB-13591
             Project: Apache Cordova
          Issue Type: Bug
          Components: cordova-plugin-file-transfer
    Affects Versions: Master
         Environment: *Android 4.2.2*

*cordova platform ls*
Installed platforms:
  android 6.2.3

*cordova plugin ls*
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-battery-status 1.1.2 "Battery"
cordova-plugin-camera 2.1.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.0.7 "Console"
cordova-plugin-contacts 2.0.1 "Contacts"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-device-motion 1.2.5 "Device Motion"
cordova-plugin-device-orientation 1.0.7 "Device Orientation"
cordova-plugin-dialogs 1.2.1 "Notification"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.5.1 "File Transfer"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-globalization 1.0.8 "Globalization"
cordova-plugin-inappbrowser 1.3.0 "InAppBrowser"
cordova-plugin-media 2.2.0 "Media"
cordova-plugin-media-capture 1.2.0 "Capture"
cordova-plugin-network-information 1.2.1 "Network Information"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-vibration 2.1.6 "Vibration"
cordova-plugin-whitelist 1.2.2 "Whitelist"
cordova-plugin-x-toast 2.6.0 "Toast"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.0.7 "Launch Navigator"

*cordova --version*
6.5.0


            Reporter: Mauricio Ramirez
            Priority: Blocker


{code:java}
                var ef = JSON.parse(localStorage.getItem(lsKey));

                var win = function (json) {
                    var response = JSON.parse(json.response);
                    localStorage.removeItem("EF"+response.data.lsKey);
                    actualizarHeader();
                    return;
                }
                var fail = function (error) {
                    var err = error;
                    n_enviarEF--;
                }

                var options = new FileUploadOptions();
                options.fileKey = "file";
                options.fileName = ef.f.substr(ef.f.lastIndexOf('/') + 1);
                options.mimeType = "image/jpeg";
                options.params = ef; // if we need to send parameters to the server request
                var ft = new FileTransfer();
                ft.upload(ef.f, encodeURI(surl), win, fail, options);
{code}

The first time this code is run, it will fail. On retry, it runs perfectly.

Messages from the monitor app.


{code:java}
First Time it is run:

11-19 12:15:54.500: D/FileTransfer(17031): upload file:///mnt/sdcard/Android/data/com.alarmar.gps/cache/1511111749734.jpg to https://xxxxxxxxxxxxxxxxxxxx.com.co/ws/gl/gl.php
11-19 12:15:54.500: D/FileTransfer(17031): fileKey: file
11-19 12:15:54.500: D/FileTransfer(17031): fileName: 1511111749734.jpg
11-19 12:15:54.500: D/FileTransfer(17031): mimeType: image/jpeg
11-19 12:15:54.500: D/FileTransfer(17031): params: {"f":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","u":"15347039","m":"setEF","ts":1511111750107,"a":"22396"}
11-19 12:15:54.500: D/FileTransfer(17031): trustEveryone: false
11-19 12:15:54.500: D/FileTransfer(17031): chunkedMode: true
11-19 12:15:54.500: D/FileTransfer(17031): headers: null
11-19 12:15:54.500: D/FileTransfer(17031): objectId: 2
11-19 12:15:54.500: D/FileTransfer(17031): httpMethod: POST
11-19 12:15:54.510: D/FileTransfer(17031): Content Length: 61589
11-19 12:15:54.540: D/FileTransfer(17031): Sent 61589 of 61589
11-19 12:15:54.550: W/FileTransfer(17031): Error getting HTTP status code from connection.
11-19 12:15:54.550: W/FileTransfer(17031): java.io.EOFException
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.io.Streams.readAsciiLine(Streams.java:203)
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
11-19 12:15:54.550: W/FileTransfer(17031): 	at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:504)
11-19 12:15:54.550: W/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-19 12:15:54.550: W/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-19 12:15:54.550: W/FileTransfer(17031): 	at java.lang.Thread.run(Thread.java:856)
11-19 12:15:54.550: E/FileTransfer(17031): {"target":"https:\/\/servicios.poblado.alarmar.com.co\/ws\/gl\/gl.php","http_status":0,"code":3,"source":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","exception":"java.io.EOFException"}
11-19 12:15:54.550: E/FileTransfer(17031): java.io.EOFException
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.io.Streams.readAsciiLine(Streams.java:203)
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
11-19 12:15:54.550: E/FileTransfer(17031): 	at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:504)
11-19 12:15:54.550: E/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-19 12:15:54.550: E/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-19 12:15:54.550: E/FileTransfer(17031): 	at java.lang.Thread.run(Thread.java:856)
11-19 12:15:54.550: E/FileTransfer(17031): Failed after uploading 61589 of 61589 bytes.

On retry:

11-19 12:16:04.550: D/FileTransfer(17031): upload file:///mnt/sdcard/Android/data/com.alarmar.gps/cache/1511111749734.jpg to https://xxxxxxxxxxxxxxxxxxxx.com.co/ws/gl/gl.php
11-19 12:16:04.550: D/FileTransfer(17031): fileKey: file
11-19 12:16:04.550: D/FileTransfer(17031): fileName: 1511111749734.jpg
11-19 12:16:04.550: D/FileTransfer(17031): mimeType: image/jpeg
11-19 12:16:04.550: D/FileTransfer(17031): params: {"f":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","u":"15347039","m":"setEF","ts":1511111750107,"a":"22396"}
11-19 12:16:04.550: D/FileTransfer(17031): trustEveryone: false
11-19 12:16:04.550: D/FileTransfer(17031): chunkedMode: true
11-19 12:16:04.550: D/FileTransfer(17031): headers: null
11-19 12:16:04.550: D/FileTransfer(17031): objectId: 3
11-19 12:16:04.550: D/FileTransfer(17031): httpMethod: POST
11-19 12:16:04.560: D/FileTransfer(17031): Content Length: 61589
11-19 12:16:04.750: D/FileTransfer(17031): Sent 61589 of 61589
11-19 12:16:05.640: D/FileTransfer(17031): response code: 200
11-19 12:16:05.640: D/FileTransfer(17031): response headers: {null=[HTTP/1.1 200 OK], access-control-allow-credentials=[true], access-control-allow-headers=[Content-Type, *], access-control-allow-methods=[GET, POST, OPTIONS], access-control-allow-origin=[*], Connection=[Keep-Alive], Content-Length=[72], Content-Type=[application/json], Date=[Sun, 19 Nov 2017 17:16:06 GMT], Keep-Alive=[timeout=5, max=100], Server=[Apache/2.4.18 (Ubuntu)], X-Android-Received-Millis=[1511111765654], X-Android-Sent-Millis=[1511111764742]}
11-19 12:16:05.650: D/FileTransfer(17031): got response from server
11-19 12:16:05.650: D/FileTransfer(17031): {"success":true,"data":{"success":true,"tk":-1,"lsKey":"1511111750107"}}
11-19 12:16:05.650: D/SystemWebChromeClient(17031): file:///android_asset/www/js/index.js: Line 439 : win: {"response":"{\"success\":true,\"data\":{\"success\":true,\"tk\":-1,\"lsKey\":\"1511111750107\"}}","responseCode":200,"objectId":"","bytesSent":61576}
11-19 12:16:05.660: I/Web Console(17031): win: {"response":"{\"success\":true,\"data\":{\"success\":true,\"tk\":-1,\"lsKey\":\"1511111750107\"}}","responseCode":200,"objectId":"","bytesSent":61576} at file:///android_asset/www/js/index.js:439

{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org