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

Gregor Gabriel edited comment on CB-2787 at 6/7/13 3:57 PM:
------------------------------------------------------------

I have the same problem.

{code:xml}
... about 300 downloads worked well ...

06-07 16:18:29.533: D/FileTransfer(6548): download 
https://elearning-mobile.de.tuv.com:443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
 to 
file:///storage/emulated/0/content/https/elearning-mobile.de.tuv.com443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
06-07 16:18:29.603: D/FileTransfer(6548): Download 
file:https://elearning-mobile.de.tuv.com:443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
06-07 16:18:29.643: E/FileTransfer(6548): 
{"target":"file:\/\/\/storage\/emulated\/0\/content\/https\/elearning-mobile.de.tuv.com443\/content\/ada\/ada06\/ada06q01-6\/sounds\/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3","source":"https:\/\/elearning-mobile.de.tuv.com:443\/content\/ada\/ada06\/ada06q01-6\/sounds\/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3","http_status":200,"code":1}
06-07 16:18:29.643: E/FileTransfer(6548): java.io.FileNotFoundException: 
/storage/emulated/0/content/https/elearning-mobile.de.tuv.com443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3:
 open failed: EMFILE (Too many open files)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.IoBridge.open(IoBridge.java:416)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.io.FileOutputStream.<init>(FileOutputStream.java:88)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.io.FileOutputStream.<init>(FileOutputStream.java:73)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
org.apache.cordova.FileTransfer$4.run(FileTransfer.java:808)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.lang.Thread.run(Thread.java:856)
06-07 16:18:29.643: E/FileTransfer(6548): Caused by: libcore.io.ErrnoException: 
open failed: EMFILE (Too many open files)
06-07 16:18:29.643: E/FileTransfer(6548):       at libcore.io.Posix.open(Native 
Method)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.IoBridge.open(IoBridge.java:400)
06-07 16:18:29.643: E/FileTransfer(6548):       ... 6 more
{code}

I use cordova 2.7 (same effect with cordova 2.2)
My app worked fine on Android 2.3, 3.x
With Android 4.0 I got this issue, but using a timeout of 1 millisecond solved 
my problem.
This workaround also worked for Android 4.1.x.

But now with Android 4.2.2 (Nexus 7) I can't get rid of this problem, even with 
bigger timeouts

My code looks like this:


{code:javascript}
var urls=['http://foo', ..., 'http://bar'];

var loader = new FileTransfer();

function loader(){
        var url = window.urls.pop();

        if(url === undefined) return;

        window.loader.download(
                url,
                window.getAbsoluteFileNameForUrl(url),
                function(e){setTimeout(loader,100)},
                function(e){setTimeout(loader,100)}
        );
}


{code}

                
      was (Author: ggabriel):
    I have the same problem.

{code:xml}
06-07 16:18:29.533: D/FileTransfer(6548): download 
https://elearning-mobile.de.tuv.com:443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
 to 
file:///storage/emulated/0/content/https/elearning-mobile.de.tuv.com443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
06-07 16:18:29.603: D/FileTransfer(6548): Download 
file:https://elearning-mobile.de.tuv.com:443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3
06-07 16:18:29.643: E/FileTransfer(6548): 
{"target":"file:\/\/\/storage\/emulated\/0\/content\/https\/elearning-mobile.de.tuv.com443\/content\/ada\/ada06\/ada06q01-6\/sounds\/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3","source":"https:\/\/elearning-mobile.de.tuv.com:443\/content\/ada\/ada06\/ada06q01-6\/sounds\/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3","http_status":200,"code":1}
06-07 16:18:29.643: E/FileTransfer(6548): java.io.FileNotFoundException: 
/storage/emulated/0/content/https/elearning-mobile.de.tuv.com443/content/ada/ada06/ada06q01-6/sounds/26B73D46-072B-43AB-ADFB-31ECBA18A975.mp3:
 open failed: EMFILE (Too many open files)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.IoBridge.open(IoBridge.java:416)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.io.FileOutputStream.<init>(FileOutputStream.java:88)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.io.FileOutputStream.<init>(FileOutputStream.java:73)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
org.apache.cordova.FileTransfer$4.run(FileTransfer.java:808)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
java.lang.Thread.run(Thread.java:856)
06-07 16:18:29.643: E/FileTransfer(6548): Caused by: libcore.io.ErrnoException: 
open failed: EMFILE (Too many open files)
06-07 16:18:29.643: E/FileTransfer(6548):       at libcore.io.Posix.open(Native 
Method)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
06-07 16:18:29.643: E/FileTransfer(6548):       at 
libcore.io.IoBridge.open(IoBridge.java:400)
06-07 16:18:29.643: E/FileTransfer(6548):       ... 6 more
{code}

I use cordova 2.7 (same effect with cordova 2.2)
My app worked fine on Android 2.3, 3.x
With Android 4.0 I got this issue, but using a timeout of 1 millisecond solved 
my problem.
This workaround also worked for Android 4.1.x.

But now with Android 4.2.2 (Nexus 7) I can't get rid of this problem, even with 
bigger timeouts

My code looks like this:


{code:javascript}
var urls=['http://foo', ..., 'http://bar'];

var loader = new FileTransfer();

function loader(){
        var url = window.urls.pop();

        if(url === undefined) return;

        window.loader.download(
                url,
                window.getAbsoluteFileNameForUrl(url),
                function(e){setTimeout(loader,100)},
                function(e){setTimeout(loader,100)}
        );
}


{code}

                  
> PhoneGap FileTransfer.Download more than 300 files
> --------------------------------------------------
>
>                 Key: CB-2787
>                 URL: https://issues.apache.org/jira/browse/CB-2787
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.5.0
>            Reporter: Cho
>            Assignee: Ian Clelland
>
> I had tried to download more than 300 files and then it hit error after that. 
> Seems like some IO Connection was not properly closed. I wrote a small code 
> to test it out. 
> Any idea? How to file a report or get a source of phonegap to check the real 
> cause?
> {code}
> var counter = 500;
> function DownloadFile() {
>         if (counter == 0) {
>             DownloadComplete();
>             return;
>         }
>         var ft = new FileTransfer();
>         var downloadUrl = "<source>";
>         var dlPath = "<target>"
>         ft.download(downloadUrl, dlPath, function(entry) {
>             counter--;
>             UpdateProgress();
>             DownloadFile();
>         }, function(error) {
>             DownloadFailed();
>         }, true);
>     }
> {code}
> note: <target> and <source> is alright because it was it failed when the 
> counter goes until 300+.
> {code}
> 03-14 08:35:09.706: E/FileTransfer(24867): 
> {"target":"<target>","source":"<source>","http_status":200,"code":1}
> 03-14 08:35:09.706: E/FileTransfer(24867): java.io.FileNotFoundException: 
> <source>: open failed: EMFILE (Too many open files)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> libcore.io.IoBridge.open(IoBridge.java:416)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> java.io.FileOutputStream.<init>(FileOutputStream.java:88)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> java.io.FileOutputStream.<init>(FileOutputStream.java:73)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> org.apache.cordova.FileTransfer$4.run(FileTransfer.java:685)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> java.lang.Thread.run(Thread.java:856)
> 03-14 08:35:09.706: E/FileTransfer(24867): Caused by: 
> libcore.io.ErrnoException: open failed: EMFILE (Too many open files)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> libcore.io.Posix.open(Native Method)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at 
> libcore.io.IoBridge.open(IoBridge.java:400)
> 03-14 08:35:09.706: E/FileTransfer(24867):     ... 6 more
> {code}

--
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