Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
DolphinA2
10 years agoNew member | Level 1
Dropbox Java API - java.net.SocketException: Too many open files
I am using Dropbox Java API to make a large amount of requests to Dropbox API to createFolder and upload files. Currently, I am doing this sequentially, that is, no parallel thread, etc. I am regu...
DolphinA2
10 years agoNew member | Level 1
Below is the script we used to create a directory structure for testing. Because Dropbox does not have any API for bulk upload, we essentially traverse the directory tree, and upload file and create directories one at a time. The program would throw "java.net.SocketException: Too many open files" error. I would say, around 20+ directory creation. I checked out your Java API source code, my guess is that there are a few places in your DBRequestUtil.java that DropboxAPI team hasn't closed the InputStream properly. One of the example is readJsonFromResponse() function call, the result is simple returned with 'return reader.readFully(body)'. I have changed it to the following:
T t = reader.readFully(body);
if ( body != null ) body.close();
return t;
______ script for creating directories for testing ________
#!/usr/local/bin//tcsh -f
set level1 = ( a b c d e f g h i j )
set level2 = ( 1 2 3 4 5 6 7 8 9 0 )
set level3 = ( p q r s t u v w x y )
set size = 1024
set count = 128
foreach aa ( $level1 )
mkdir $aa
dd if=/dev/random of=$aa/file$aa.txt count=$count bs=$size
foreach bb ( $level2 )
mkdir $aa/$bb
dd if=/dev/zero of=$aa/$bb/file$aa$bb.txt count=$count bs=$size
foreach cc ( $level3 )
mkdir $aa/$bb/$cc
dd if=/dev/zero of=$aa/$bb/$cc/file$aa$bb$cc.txt count=$count bs=$size
end
end
end
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!