Giter Club home page Giter Club logo

Comments (12)

alexbbb avatar alexbbb commented on May 18, 2024

Follow the example here: https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status

@Override
public void onCompleted(String uploadId,
                        int serverResponseCode,
                        String serverResponseMessage) {
    Log.i(TAG, "Upload with ID " + uploadId
               + " is completed: " + serverResponseCode
               + ", " + serverResponseMessage);
    //Use a library such as org.json or google gson 
    //to parse JSON from serverResponseMessage string
}

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

Hi, I ‘ve done it at beginning and suppose that serverResponseMessage would be son but NOT. it is representation(key=value) of serverReponseCode.
So I mean that if serverResponseCode is 200-> serverResponseMessage display in debugger(LogCat) OK.
Next, if server/php side set http_response_code(202); then LogCat display serverResponseCode 202 -> and serverResponseMessage: Accepted.

Believe me, I tested serveral times to debug it up and down but could not get json response from server eve I send it from.
I would not bother you if did not read your manual and implementation steps.

serverResponseMessage is only velue representation of serverResponseCode BUT I need json response data that I sent from server side like:
http_response_code(200);
$result['data'] = array(‘picName’=>’abc.jpg’, ’status’=>’OK');

$json = json_encode($result);

header("Content-Type: application/json", true);
exit($json);

Have you tried it, get json response from server to upload service?
Thanks for help, indeed.

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 09:50, Alex Gotev [email protected] wrote:

Follow the example here: https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status
@OverRide
public void onCompleted(String uploadId,
int serverResponseCode,
String serverResponseMessage) {
Log.i(TAG, "Upload with ID " + uploadId
+ " is completed: " + serverResponseCode
+ ", " + serverResponseMessage);
//Use a library such as org.json or google gson
//to parse JSON from serverResponseMessage string
}

Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

alexbbb avatar alexbbb commented on May 18, 2024

I've made some modifications to read response body from the server: 140bef1

Please update the library, try again as I suggested you in the previous comment and let me know what you get in "serverResponseMessage"

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

Hi Alex,

That modification is exactly what I needed(InputStream data) to proceed server response data in android, great it works.
Thanks again. Enj day.

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 10:54, Alex Gotev [email protected] wrote:

I've made some modifications to read response body from the server: 140bef1 140bef1
Please update the library, try again as I suggested you in the previous comment and let me know what you get in "serverResponseMessage"


Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

alexbbb avatar alexbbb commented on May 18, 2024

Thank you for your feedback 👍 and I'm glad that everything works now :)

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

Hi Alex,

Just note. Next customization that I had to do in your upload android service was:

UploadService
getMultipartHttpURLConnection
conn.setRequestProperty("Connection", "close");
// conn.setRequestProperty("Connection", "Keep-Alive”);

http://tiku.io/questions/782960/java-net-socketexception-sendto-failed-epipe-broken-pipe-on-android http://tiku.io/questions/782960/java-net-socketexception-sendto-failed-epipe-broken-pipe-on-android

Cause every 2nd request to send multipart(Picture+data) to server was with exception:
01-11 14:07:24.920: I/CameraActivity(650): The progress of the upload with ID c88f3352-7a39-403f-8351-981b88dd79c3 is: 4
01-11 14:07:25.065: D/dalvikvm(650): GC_FOR_ALLOC freed 2934K, 30% free 13180K/18624K, paused 22ms, total 22ms
01-11 14:07:25.110: E/CameraActivity(650): Error in upload with ID: c88f3352-7a39-403f-8351-981b88dd79c3. sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): java.net.SocketException: sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:499)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.sendto(IoBridge.java:468)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.writeHex(ChunkedOutputStream.java:102)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.writeBufferedChunkToSocket(ChunkedOutputStream.java:128)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.write(ChunkedOutputStream.java:77)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.uploadFiles(UploadService.java:265)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.handleFileUpload(UploadService.java:166)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:137)
01-11 14:07:25.110: E/CameraActivity(650): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.Looper.loop(Looper.java:176)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.HandlerThread.run(HandlerThread.java:61)
01-11 14:07:25.110: E/CameraActivity(650): Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.Posix.sendtoBytes(Native Method)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.Posix.sendto(Posix.java:155)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.sendto(IoBridge.java:466)
01-11 14:07:25.110: E/CameraActivity(650): ... 13 more

OR

01-11 14:12:23.165: E/CameraActivity(7394): Error in upload with ID: 7f190d3e-8edc-40fa-a7a3-c6f18c05e6d0. null
01-11 14:12:23.165: E/CameraActivity(7394): java.io.EOFException
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.io.Streams.readAsciiLine(Streams.java:203)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
01-11 14:12:23.165: E/CameraActivity(7394): at com.alexbbb.uploadservice.UploadService.handleFileUpload(UploadService.java:170)
01-11 14:12:23.165: E/CameraActivity(7394): at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:137)
01-11 14:12:23.165: E/CameraActivity(7394): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.Looper.loop(Looper.java:176)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.HandlerThread.run(HandlerThread.java:61)

OR Socket Exceprion pointing to EPIPE

So to explain:

  • 1st android/http request opened socket con, server closed, but service kept opened.
  • 2nd request wanted to used before user con->so socket, but exceptionraised cause server do not have before used socket keep alive, closed, ended. Then android/http con closed too.
  • 3rd reuest like 1st
  • 4th like 2ns, crashed and so on.

It is right to use keep alive connection opened while uploading batch files, I mean 6 pictures in one time, batch upload.
Just note, if other met the same problem ;)
Enj day.

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 11:29, Alex Gotev [email protected] wrote:

Thank you for your feedback and I'm glad that everything works now :)


Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

alexbbb avatar alexbbb commented on May 18, 2024

This error happened also to other users in the past, but none of them gave me a log to work with and an exact step-by-step description of how to reproduce the error. I've reproduced the error you described and by applying your solution, the problem is resolved, so I committed your patch: 60ecf22

Just update the library and you're good to go ;)

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

I like to help you ;)
Property about uploading should be set before start request like:
enum{
SINGLE_UPLOAD, ->Con close
BATCH_UPLOAD -> Con Keep Alive
}

I customize more yor code and let you know, but fix Con:close works 100%. Now I building/testing one app and works perfect.
Thanks again ;)

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 14:11, Alex Gotev [email protected] wrote:

This error happened also to other users in the past, but none of them gave me a log to work with and an exact step-by-step description of how to reproduce the error. I've reproduced the error you described and by applying your solution, the problem is resolved, so I committed your patch: 60ecf22 60ecf22
Just update the library and you're good to go ;)


Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

alexbbb avatar alexbbb commented on May 18, 2024

By batch upload you mean an UploadRequest on which you add more than one file (by calling addFileToUpload N times) or you're making N calls to UploadService.startUpload(request) ?

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

1option

UploadRequest on which you add more than one file (by calling addFileToUpload)

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 14:33, Alex Gotev [email protected] wrote:

By batch upload you mean an UploadRequest on which you add more than one file (by calling addFileToUpload) or you're making N calls to UploadService.startUpload(request) ?


Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

alexbbb avatar alexbbb commented on May 18, 2024

Ok, so to keep things simple and transparent to the users of the library, I set connection keep-alive only if there is more than one file to upload, otherwise I set it to connection close. Commit: 9a7b35b

from android-upload-service.

juniorJaffa avatar juniorJaffa commented on May 18, 2024

exactly ;) good fix

Regards,

Ing. Marian Kubincanek
Senior Java Developer

LinkedIn:  http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek

On Jan 28, 2015, at 14:40, Alex Gotev [email protected] wrote:

Ok, so to keep things simple and transparent to the users of the library, I set connection keep-alive only if there is more than one file to upload, otherwise I set it to connection close. Commit: 9a7b35b 9a7b35b

Reply to this email directly or view it on GitHub #15 (comment).

from android-upload-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.