File Uploading - SocketTimeoutException: Read timed out
J
Janaka Jayasuriya
started a topic
about 7 years ago
I'm trying to upload a file from my android device, but I get:
java.net.SocketTimeoutException: Read timed out.
I do see the file uploaded on the Kinvey Console, but it's corrupted and the file size when I try to download is 10mb, where as the original file size is ~50mb. The code is as follows (pretty close to the documentation):
File file = new File(Environment.getExternalStorageDirectory(), "images.zip");
FileMetaData metadata = new FileMetaData(); //create the FileMetaData object
metadata.setId("images");
metadata.setFileName("images.zip");
AccessControlList acl = new AccessControlList();
acl.setGloballyReadable(true);
metadata.setAcl(acl);
mKinveyClient.file().upload(metadata, file, new UploaderProgressListener() {
@Override
public void onSuccess(Void arg0) {
// TODO Auto-generated method stub
}
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
}
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
Hey, this usually occurs because of an unreliable internet connection. Also, note, 50mb is a large file! Are you on wifi or a data plan? Is this on an emulator or a physical device?
I would recommend getting your app to require wifi to download this, which should improve the connection. Also, have you attempted to retry the download if it fails?
J
Janaka Jayasuriya
said
about 7 years ago
@Edward
For upload. It's on a physical device (HTC One). I have tested both on local WiFi network and my LTE connection. Both are very reliable.
I'm testing the file download from the Kinvey Web Console on the browser. It's a zip file by the way and, and it's corrupted, and the file size is 10mb.
I have tested this problem further now, and noticed that files under 10mb work fine. But files over 10mb have a problem. 10mb is pretty arbitrary, it is not mentioned anywhere in the documentation that there is a limit like this.
Is there anyone from Kinvey who can help me please? This has brought my development to a standstill.
J
Janaka Jayasuriya
said
about 7 years ago
Can anyone help?
E
Edward
said
about 7 years ago
Hey, I'm still investigating this one-- it is difficult to troubleshoot this kind of issue because there are so many factors involved.
What version of android are you running on your HTC one?
As a workaround, is it a possibility to upload the individual artifacts instead of the archive?
J
Janaka Jayasuriya
said
about 7 years ago
@Edward
I'm just using a regular HTC One, with android 4.3. Were you able to recreate the problem on any of your devices?
My application needs require the files to be in an archive. As a workaround I'm currently storing the files in a different service and saving the link as a reference.
I've also tried uploading files via the REST API (following the guide on Kinvey), I couldn't get that working either. I get a signature mismatch error. We can't afford to spend more time debugging this so I we opted to store the files elsewhere, though we want to eventually get everything under one service. So please keep me updated on your progress.
Is there a limit for the file size that can be stored? In the future we expect to have 100~200mb files. In the documentation it's not mentioned (or I missed it), just that via the web console, uploads are limited to 20mb files. Lifting this limitation could also help us a lot, so we can just upload via the web console.
Janaka Jayasuriya
java.net.SocketTimeoutException: Read timed out.
I do see the file uploaded on the Kinvey Console, but it's corrupted and the file size when I try to download is 10mb, where as the original file size is ~50mb. The code is as follows (pretty close to the documentation):
File file = new File(Environment.getExternalStorageDirectory(), "images.zip");
FileMetaData metadata = new FileMetaData(); //create the FileMetaData object
metadata.setId("images");
metadata.setFileName("images.zip");
AccessControlList acl = new AccessControlList();
acl.setGloballyReadable(true);
metadata.setAcl(acl);
mKinveyClient.file().upload(metadata, file, new UploaderProgressListener() {
@Override
public void onSuccess(Void arg0) {
// TODO Auto-generated method stub
}
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
}
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
}
});