Ion timeout post file to sails(skipper)

275 views Asked by At

My situation is when I post a jpg file to my Sails server in Android with Ion, it went timeout. Here is my code:

Android:

Ion.with(ctx, URLConstant.getURL(URLConstant.URL_TYPE_UPLOAD_AVATAR))
            .setMultipartFile("avatar", new File("assets/avatar.jpg"))
            .asJsonObject()
            .setCallback(new FutureCallback<JsonObject>() {
                @Override
                public void onCompleted(Exception e, JsonObject result) {
                    if (e != null) {
                        System.out.println("Upload file error.");
                        e.printStackTrace();
                        return;
                    }
                    System.out.println("Upload file done");
                }
            })

My server code is:

console.log(funcName + "Start to upload file");

    req.file('avatar').upload({
        maxBytes: sails.config.assetsConfig.maxBytes,
        saveAs: user_id + '-' + sid.generate() + '.jpg',
        dirname: sails.config.assetsConfig.uploadDir + '/avatar/'
      }, function (err, uploadedFiles) {

        console.log(funcName + "Upload done");

The server works fine with POSTMAN but not with Ion, "Start to upload file" logged but not "Upload Done", eventually I got TimeOutException at client like below:

11-20 19:58:41.364: W/System.err(5165): java.util.concurrent.TimeoutException
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.http.AsyncHttpClient$2.run(AsyncHttpClient.java:196)
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.AsyncServer.lockAndRunQueue(AsyncServer.java:675)
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:692)
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:600)
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
11-20 19:58:41.364: W/System.err(5165):     at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:549)

Could anyone give me a clue about it. Best regards.

0

There are 0 answers