[ 
https://issues.apache.org/jira/browse/CB-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13753360#comment-13753360
 ] 

John Croucher edited comment on CB-2293 at 8/29/13 7:05 AM:
------------------------------------------------------------

I can confirm it is still an issue in version 3.0.0.

It occurs for me intermittently, on a HTC phone, and any virtual devices.

I have tried the suggested fixes. 

- Add System.setProperty("http.keepAlive", "false");
- Remove conn.setRequestProperty("Connection", "Keep-Alive"); from 
FileTransfer.java. It already does not exist.

I can also confirm that when the error occurs it is *not* hitting the server at 
all, even though it says Sent 15007 of 15007.


08-29 15:06:55.172: D/FileTransfer(531): upload 
content://media/external/images/media/14 to 
http://exampledomain.com?page=do_upload
08-29 15:06:55.172: D/FileTransfer(531): fileKey: image
08-29 15:06:55.172: D/FileTransfer(531): fileName: 14
08-29 15:06:55.172: D/FileTransfer(531): mimeType: image/jpeg
08-29 15:06:55.172: D/FileTransfer(531): params: {}
08-29 15:06:55.172: D/FileTransfer(531): trustEveryone: true
08-29 15:06:55.172: D/FileTransfer(531): chunkedMode: false
08-29 15:06:55.172: D/FileTransfer(531): headers: null
08-29 15:06:55.172: D/FileTransfer(531): objectId: 1
08-29 15:06:55.172: D/FileTransfer(531): httpMethod: POST
08-29 15:06:55.192: D/FileTransfer(531): Content Length: 15007
08-29 15:06:55.202: D/FileTransfer(531): Sent 15007 of 15007
08-29 15:06:55.202: W/PluginManager(531): THREAD WARNING: exec() call to 
FileTransfer.upload blocked the main thread for 54ms. Plugin should use 
CordovaInterface.getThreadPool().
08-29 15:06:55.212: W/FileTransfer(531): Error getting HTTP status code from 
connection.
08-29 15:06:55.212: W/FileTransfer(531): java.io.EOFException
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534)
08-29 15:06:55.212: W/FileTransfer(531):    at 
org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.lang.Thread.run(Thread.java:856)
08-29 15:06:55.223: E/FileTransfer(531): 
{"target":"http:\/\/exampledomain.com\/?page=do_upload","source":"content:\/\/media\/external\/images\/media\/14","http_status":0,"code":3}
08-29 15:06:55.223: E/FileTransfer(531): java.io.EOFException
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534)
08-29 15:06:55.223: E/FileTransfer(531):    at 
org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.lang.Thread.run(Thread.java:856)
08-29 15:06:55.223: E/FileTransfer(531): Failed after uploading 15007 of 15007 
bytes.


**Update**
In addition to disabling chunking, I have added a header option which **so 
far** seems to have fixed the issue
{code}
        var options = new FileUploadOptions();

        options.headers = {
                Connection: "close"
        }
        options.chunkedMode = false;


        ft.upload(imgUrl, PATH, uploadSuccess, uploadFail, options);
{code}
                
      was (Author: jcroucher):
    I can confirm it is still an issue in version 3.0.0.

It occurs for me intermittently, on a HTC phone, and any virtual devices.

I have tried the suggested fixes. 

- Add System.setProperty("http.keepAlive", "false");
- Remove conn.setRequestProperty("Connection", "Keep-Alive"); from 
FileTransfer.java. It already does not exist.

I can also confirm that when the error occurs it is *not* hitting the server at 
all, even though it says Sent 15007 of 15007.


08-29 15:06:55.172: D/FileTransfer(531): upload 
content://media/external/images/media/14 to 
http://exampledomain.com?page=do_upload
08-29 15:06:55.172: D/FileTransfer(531): fileKey: image
08-29 15:06:55.172: D/FileTransfer(531): fileName: 14
08-29 15:06:55.172: D/FileTransfer(531): mimeType: image/jpeg
08-29 15:06:55.172: D/FileTransfer(531): params: {}
08-29 15:06:55.172: D/FileTransfer(531): trustEveryone: true
08-29 15:06:55.172: D/FileTransfer(531): chunkedMode: false
08-29 15:06:55.172: D/FileTransfer(531): headers: null
08-29 15:06:55.172: D/FileTransfer(531): objectId: 1
08-29 15:06:55.172: D/FileTransfer(531): httpMethod: POST
08-29 15:06:55.192: D/FileTransfer(531): Content Length: 15007
08-29 15:06:55.202: D/FileTransfer(531): Sent 15007 of 15007
08-29 15:06:55.202: W/PluginManager(531): THREAD WARNING: exec() call to 
FileTransfer.upload blocked the main thread for 54ms. Plugin should use 
CordovaInterface.getThreadPool().
08-29 15:06:55.212: W/FileTransfer(531): Error getting HTTP status code from 
connection.
08-29 15:06:55.212: W/FileTransfer(531): java.io.EOFException
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334)
08-29 15:06:55.212: W/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534)
08-29 15:06:55.212: W/FileTransfer(531):    at 
org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-29 15:06:55.212: W/FileTransfer(531):    at 
java.lang.Thread.run(Thread.java:856)
08-29 15:06:55.223: E/FileTransfer(531): 
{"target":"http:\/\/exampledomain.com\/?page=do_upload","source":"content:\/\/media\/external\/images\/media\/14","http_status":0,"code":3}
08-29 15:06:55.223: E/FileTransfer(531): java.io.EOFException
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334)
08-29 15:06:55.223: E/FileTransfer(531):    at 
com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534)
08-29 15:06:55.223: E/FileTransfer(531):    at 
org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-29 15:06:55.223: E/FileTransfer(531):    at 
java.lang.Thread.run(Thread.java:856)
08-29 15:06:55.223: E/FileTransfer(531): Failed after uploading 15007 of 15007 
bytes.

                  
> File Transfer of picture fails on every other picture
> -----------------------------------------------------
>
>                 Key: CB-2293
>                 URL: https://issues.apache.org/jira/browse/CB-2293
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.2.0, 2.3.0
>         Environment: Tested on a Motorola Atrix HD(Android 4.1.2) as well as 
> a Samsung Galaxy S3(Android 4.1.1)
>            Reporter: Amrit Kahlon
>            Assignee: Ian Clelland
>             Fix For: 2.8.0
>
>         Attachments: cordova-2.4.0rc1.jar
>
>
> When uploading pictures using the File Transfer function on android, the 
> first picture will upload fine. Then the second upload will give the 
> following error:
> 01-21 13:48:02.545: W/FileTransfer(8894): Error getting HTTP status code from 
> connection.
> 01-21 13:48:02.545: W/FileTransfer(8894): java.io.EOFException
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> libcore.io.Streams.readAsciiLine(Streams.java:203)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> org.apache.cordova.FileTransfer.createFileTransferError(FileTransfer.java:535)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> org.apache.cordova.FileTransfer.access$500(FileTransfer.java:62)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> org.apache.cordova.FileTransfer$1.run(FileTransfer.java:437)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> 01-21 13:48:02.545: W/FileTransfer(8894):     at 
> java.lang.Thread.run(Thread.java:856)
> 01-21 13:48:02.555: E/FileTransfer(8894): 
> {"target":"http:\/\/xxx.xxx.xxx\/api\/photo_uploads\/create?version=2&api_key=xxxxxxxxx&source=androidapp-2.2.1","source":"file:\/\/\/storage\/sdcard0\/Android\/data\/com.hockeycommunity.hc_app\/cache\/resize.jpg?1358804880392","code":3}
> 01-21 13:48:02.555: E/FileTransfer(8894): java.net.SocketException: sendto 
> failed: EPIPE (Broken pipe)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.IoBridge.sendto(IoBridge.java:475)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:270)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.net.http.FixedLengthOutputStream.write(FixedLengthOutputStream.java:41)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.io.DataOutputStream.write(DataOutputStream.java:98)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> org.apache.cordova.FileTransfer$1.run(FileTransfer.java:372)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> java.lang.Thread.run(Thread.java:856)
> 01-21 13:48:02.555: E/FileTransfer(8894): Caused by: 
> libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.Posix.sendtoBytes(Native Method)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.Posix.sendto(Posix.java:146)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
> 01-21 13:48:02.555: E/FileTransfer(8894):     at 
> libcore.io.IoBridge.sendto(IoBridge.java:473)
> 01-21 13:48:02.555: E/FileTransfer(8894):     ... 9 more
> 01-21 13:48:02.575: D/CordovaLog(8894): error: 
> {"code":3,"source":"file:///storage/sdcard0/Android/data/com.hockeycommunity.hc_app/cache/resize.jpg?1358804880392","target":"http://xxx.xxx.xxxx/api/photo_uploads/create?version=2&api_key=xxxxxxx&source=androidapp-2.2.1","http_status":null}
> 01-21 13:48:02.575: I/Web Console(8894): error: 
> {"code":3,"source":"file:///storage/sdcard0/Android/data/com.hockeycommunity.hc_app/cache/resize.jpg?1358804880392","target":"http://xxx.xxx.xxx/api/photo_uploads/create?version=2&api_key=xxxxxxx&source=androidapp-2.2.1","http_status":null}
>  at file:///android_asset/www/interfaces/int.upload_picture.js:28
> Then the next picture will upload fine, and the next one will get the same 
> error code. Every other picture upload works.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to