我在我的应用程序中使用解析为我的后端而且我得到了一个奇怪的例外,我只是想弄清楚为什么,我不确定这是我的问题或解析结束,所以我想id问在这里也许有人可以帮助我。
我发现了类似的帖子 "here" ,但它没有答案,我的问题非常相似,因为我的查询有时也需要很长时间(一次)保存查询花了5个小时),有时我得到这个例外:
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
现在发生这种情况最多的代码片段也恰好是应用程序中最关键的部分,下面是非常自我解释但它是更新用户(我不是使用Parse用户而是我自己的自我解释的自定义用户类)如果由于某种原因该对象不存在ei错误地删除了,我们注册了一个新的,异常总是从外部public void done(ParseObject parseUser, ParseException e)
方法抛出,解析错误代码总是100(ConnectionFailed - 表示与Parse服务器的连接失败。),这里是代码:
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();
}
}
}
});
}
无论谁设法帮助我,这都是惊人的,我会跪在他们面前,如果我错过任何信息,请告诉我,我会确保更新我的帖子。
如果我没有得到答案,我将尝试通过电子邮件发送解析,并确保一旦我找到我将与大家分享这个的原因,因为我知道这个问题是多么令人沮丧。
非常感谢堆栈溢出社区!
答案 0 :(得分:0)
我不确定导致此错误的是什么,但我可以提出3件事:
在Parse仪表板中,转到您自定义的用户表&gt;安全&gt;高级,并检查是否为每个人或至少为相应的ParseUser对象启用了GET。
如果一切正常,可以尝试不同的方法:使用User.getId()参数创建一个没有数据的对象,然后在该对象上调用fetchInBackground()。
如果这也不起作用,请联系Parse支持部门(报告错误)。