parse-community/ParseLiveQuery-Android

subscribe Error

kkbpower opened this issue · 10 comments

ParseQuery query = ParseQuery.getQuery("Chat");
client = ParseLiveQueryClient.Factory.getClient();
SubscriptionHandling subscriptionHandling = client.subscribe(query);

What is this error?

E/ParseLiveQueryClient: Error handling message
com.parse.LiveQueryException$InvalidResponseException: {"op":"error","error":"Key in request is not valid","code":4,"reconnect":true}
at com.parse.ParseLiveQueryClientImpl.parseMessage(ParseLiveQueryClientImpl.java:268)
at com.parse.ParseLiveQueryClientImpl.access$000(ParseLiveQueryClientImpl.java:24)
at com.parse.ParseLiveQueryClientImpl$1.call(ParseLiveQueryClientImpl.java:201)
at com.parse.ParseLiveQueryClientImpl$1.call(ParseLiveQueryClientImpl.java:199)
at bolts.Task$4.run(Task.java:357)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)

Help me plz!

Key in request is not valid

Did you initialized parse with your API key ?

Sure. I did initialization in my custom application. So I used the cloud call!

You should only need

        Parse.Configuration build = new Parse.Configuration.Builder(this)
                .applicationId(applicationId)
                .clientKey(clientKey)
                .server(serverUrl)
                .build();
        Parse.initialize(build);

This is source of the error triggered in the server
https://github.com/parse-community/parse-server/blob/ce7ff2ca441da2956f779e7d41dc42da2db01c7d/src/LiveQuery/ParseLiveQueryServer.js#L576-L580
https://github.com/parse-community/parse-server/blob/ce7ff2ca441da2956f779e7d41dc42da2db01c7d/src/LiveQuery/ParseLiveQueryServer.js#L609-L622

It seem to be an issue with the valid keys you are using.

@flovilmart Is it an issue why the parse live query server configuration? Why would it expect a list of valid keyPairs?

My Custom Application class

Parse.Configuration.Builder parseConfigBuilder = new Parse.Configuration.Builder(this);
parseConfigBuilder.applicationId(applicationId);
parseConfigBuilder.clientKey(clientKey);
parseConfigBuilder.server(myServerURL);
Parse.initialize(parseConfigBuilder.build());

I am using many cloud call and it's okay.
But only occurred error about live query.
So when I tried to implement live query on mac os app by objective c, It was okay.

@rommansabbir I don't use Back4App!
But your answer is using the Back4App.

@kkbpower You need parse live query service right? I had a problem with liveQuery and i solved it. Try this if this project satisfy your problem

@mmimeault I saw your links.
ParseLiveQueryServer need keypairs. javascriptKey and appId are in keypairs map variable.
But just set serverURL, appId and clientKey when I set the Parse initializationg in Android.

Is this issue ParseLiveQuery bug?

@rommansabbir

Well on my side live query is working for 2 years now without any issue like that.
What is the version of the parse server you are using .
I will try to help you.

keyPair

A JSON object that serves as a whitelist of keys. It is used for validating clients when they try to connect to the LiveQuery server

What happens if you remove keyPair from your server config? I don't think its required to have keyPairs, where did you see that?

Can you post your server config?

As always you could also debug your server in the locations @mmimeault pointed out.