简体   繁体   中英

Android - Parse.com - ParseRequestException: bad protocol

I am using parse for my backend in my application and i have been getting a weird exception that i just cant figure out why, i am not sure if this is a problem on my end or on parses end so i thought id ask here maybe someone could help me.

i found a similar post "here" but it has no answers, my problem is very similar as my queries sometimes also take a very long time(once it took 5 hours to save a query) and sometimes i get this exception:

    com.parse.ParseRequest$ParseRequestException: bad protocol
at com.parse.ParseRequest.java.util.concurrent.ThreadPoolExecutor newThreadPoolExecutor(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.ThreadFactory)(Unknown Source)
                       void initialize(android.content.Context)
                       bolts.Task onPreExecute(bolts.Task)
                       com.parse.ParseHttpBody newBody(com.parse.ProgressCallback)
                       com.parse.ParseHttpRequest newRequest(com.parse.ParseRequest$Method,com.parse.ProgressCallback)
                       bolts.Task onResponse(com.parse.ParseHttpResponse,com.parse.ProgressCallback)
                       bolts.Task executeAsync(com.parse.ProgressCallback,com.parse.ProgressCallback)
                       bolts.Task executeAsync(int,long,com.parse.ProgressCallback)
                       com.parse.ParseException newPermanentException(int,java.lang.String)
                       com.parse.ParseException newTemporaryException(java.lang.String,java.lang.Throwable)
                       com.parse.ParseHttpRequest access$000(com.parse.ParseRequest)
                       com.parse.ParseHttpRequest access$002(com.parse.ParseRequest,com.parse.ParseHttpRequest)
                       bolts.Task access$300(com.parse.ParseRequest,int,long,com.parse.ProgressCallback)
at com.parse.ParseRequest$2.bolts.Task then(bolts.Task)(Unknown Source)
at com.parse.ParseRequest$2.java.lang.Object then(bolts.Task)(Unknown Source)
at bolts.Task$14.void run()(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
 Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:589)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:511)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:489)
at com.parse.ParseApacheHttpClient.com.parse.ParseHttpResponse execute(com.parse.ParseHttpRequest)(Unknown Source)
                                com.parse.ParseHttpResponse getResponse(org.apache.http.HttpResponse)
                                void setParseRequestCancelRunnable(com.parse.ParseHttpRequest,org.apache.http.client.methods.HttpUriRequest)
at com.parse.ParseRequest$3.bolts.Task then(bolts.Task)(Unknown Source)
at com.parse.ParseRequest$3.java.lang.Object then(bolts.Task)(Unknown Source)
at bolts.Task$14.void run()(Unknown Source)
at bolts.BoltsExecutors$ImmediateExecutor.void execute(java.lang.Runnable)(Unknown Source)
at bolts.Task.boolean isFaulted()(Unknown Source)
           bolts.Task onSuccessTask(bolts.Continuation,java.util.concurrent.Executor)
           bolts.Task onSuccessTask(bolts.Continuation,java.util.concurrent.Executor,bolts.CancellationToken)
           bolts.Task onSuccessTask(bolts.Continuation)
           void completeAfterTask(bolts.Task$TaskCompletionSource,bolts.Continuation,bolts.Task,java.util.concurrent.Executor,bolts.CancellationToken)
at bolts.Task.boolean isCompleted()(Unknown Source)
           bolts.Task continueWithTask(bolts.Continuation,java.util.concurrent.Executor)
           bolts.Task continueWithTask(bolts.Continuation,java.util.concurrent.Executor,bolts.CancellationToken)
           bolts.Task continueWithTask(bolts.Continuation)
           void access$200(bolts.Task$TaskCompletionSource,bolts.Continuation,bolts.Task,java.util.concurrent.Executor,bolts.CancellationToken)
           boolean access$400(bolts.Task)
           boolean access$502(bolts.Task,boolean)
at bolts.Task.boolean isCompleted()(Unknown Source)
           bolts.Task continueWithTask(bolts.Continuation,java.util.concurrent.Executor)
           bolts.Task continueWithTask(bolts.Continuation,java.util.concurrent.Executor,bolts.CancellationToken)
           bolts.Task continueWithTask(bolts.Continuation)
           void access$200(bolts.Task$TaskCompletionSource,bolts.Continuation,bolts.Task,java.util.concurrent.Executor,bolts.CancellationToken)
           boolean access$400(bolts.Task)
           boolean access$502(bolts.Task,boolean)
at bolts.Task$12.bolts.Task then(bolts.Task)(Unknown Source)
at bolts.Task$12.java.lang.Object then(bolts.Task)(Unknown Source)
... 4 more
 Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:587)
... 16 more

now the piece of code where this happens the most which also happens to be the most critical part of the app is below, it is pretty self explanatory but it is to update the user(i am not using Parse User but my own custom user class for my own reasons) on parse and if for some reason the object does not exist ei was deleted by mistake, we register a new one, the exception is always thrown from the outer public void done(ParseObject parseUser, ParseException e) method and the parse error code is always 100(ConnectionFailed - indicating the connection to the Parse servers failed.), here is the code:

public void updateUser(final User user) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(TABLE_NAME);

    query.getInBackground(user.getId(), new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject parseUser, ParseException e) {
            if (e == null) {
                parseUser.put(FIRST_NAME, user.getFirstName());
                parseUser.put(LAST_NAME, user.getLastName());
                parseUser.put(PASSWORD, user.getPassword());
                parseUser.put(COUNTRY, user.getCountry());
                parseUser.put(EMAIL, user.getEmail());
                parseUser.put(TELE, user.getTelephone());
                parseUser.put(IS_REGISTERED, user.isRegistered());
                parseUser.put(IS_ADMIN, user.isAdmin());
                parseUser.saveInBackground(new SaveCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e != null) {
                            TILogger.getLog().e(LOG_TAG, "Failed to save user in background with object id " + user.getId() + "to parse in ParseUserHelper.updateUser()",
                                    e, true, ParseHelper.LOG_FILE_NAME, true);
                        }
                    }
                });
            } else {
                TILogger.getLog().e(LOG_TAG, "Could not get user with object id " + user.getId() + " to update in ParseUserHelper.updateUser(), Parse error code: " + e.getCode()
                        + "\nUser information: first name = " + user.getFirstName() + ", last name = " + user.getLastName() + ", email = " + user.getEmail() + ", telephone = " + user.getTelephone(), e, true, ParseHelper.LOG_FILE_NAME, true);
                if(e.getCode() == ParseException.OBJECT_NOT_FOUND) {
                    registerUserToParse();
                }
            }
        }
    });
}

Whoever manages to help me with this is amazing and i will kneel before them, if i have missed any information please tell me and i will make sure to update my post.

If i get no answers i will try to email parse and will make sure that once i find the reason that i will share this with everyone as i know how frustrating this problem is.

Thank you great community of stack overflow!

I'm not sure what's causing this error, but I can suggest 3 things:

  1. In Parse dashboard, Go to your customized User table > Security > Advanced, and check if GET is enabled for everyone or at least for the corresponding ParseUser object.

  2. If everything's OK, maybe try a different approach: create an object without data with the User.getId() parameter, then call fetchInBackground() on that object.

  3. If that won't work either, contact Parse support (report a bug).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM