503 and 400 on uploading images in Google App Engi

2019-04-09 03:10发布

Recently I experienced two problems in uploading files to my Java gae app. I'm using the tecnique described in the blobstore doc.

  1. With regular files, occasionally (let's say 15% of times) the client receives a "503 Service Unavailable".
  2. With high resolution images (example 7000x10000) the client always receives a "400 Bad Request".

On both cases on the server there are no error messages logged, the blobs are written correctly, but the successPath url (the callback of createUploadUrl) is never called. It seems that the GAE endpoint handling the upload crashes for some reasons.

My client is a js XMLHttpRequest, wrapped in GWT:

public native void uploadWithXMLHttpRequest(UploadForm uploadForm) /*-{
    var fd = new FormData();
    var files = uploadForm.@mypackage.UploadForm::getFiles()();  
    for (var i = 0; i < files.length; i++) {
        fd.append("uploadFile"+i, files[i]);
    }
    var xhr = new XMLHttpRequest();
    //xhr.upload.addEventListeners... omitted
    xhr.open("POST", uploadForm.@mypackage.UploadForm::getUploadUrl()());
    xhr.send(fd);
}

Any ideas for possible causes and solutions/workarounds? Thx.

4条回答
SAY GOODBYE
2楼-- · 2019-04-09 03:29

Possible reason:

1 You uploading large file (> 1MB) and writing it all. You should write it portinal: 1 write = 1MB.

2 Your request takes longer than 30 sec - use backend.

查看更多
迷人小祖宗
3楼-- · 2019-04-09 03:42

In this case the 503 is caused by errors when we write the upload info into your datastore. As you are using M/S datastore then transient errors are expected from time to time. I suggest you convert your app to HRD to minimize the chances of there being errors related to writing the upload information to your datastore.

The 400 error was generated by your app & is in your application logs.

查看更多
戒情不戒烟
4楼-- · 2019-04-09 03:51

This issue is being discussed in a GAE ticket opened by another user having the same problem: https://code.google.com/p/googleappengine/issues/detail?id=7619 (btw, the bug tracker system has a "start" feature, which allows you to vote for the ticket and receive notifications)

查看更多
做自己的国王
5楼-- · 2019-04-09 03:52

Try to use Google Cloud Storage, since the blob store service has lot of problem, so google is trying to migrate uses from Blob to GCS support

I guess the image resolution can't exceed 8000 in the app engine blob store that is the reason it caused.

查看更多
登录 后发表回答