Whats the api endpoint for Live Queries?

I’m planning to add live chat to my app. I will use live query. But in front of my parse servers, I have nginx as reverse proxy. I want to direct live query to specific server. But rest guide on docs doesnt have any endpoint for live queries.

Whats the endpoint for live queries? Or how can I send live query requests to same server on nginx?

Ok I found this

Docs says live query listens ws://localhost:8080/

So live query doesnt have an endpoint. But It simply listen different port? Is that correct? Can anyone confirm?

Edit: And how android api use this. We dont enter any url to livequery and live query use default parse server endpoint. How can we determine if app send live query or normal request?

LiveQuery uses websockets so you need to upgrade your connection to ws:// or wss://, If you are running your Live Query server on the same port as your parse server, you can use that. It’s recommend to separate your live query server though:

You can look at the spec to see how to establish a connection with a live query server:

1 Like

Thanks. I know It uses ws protocol but I have a question. We initialize parse server like this:

Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("YOUR_APP_ID")
      // if defined
      .clientKey("YOUR_CLIENT_KEY")
      .server("http://server:1337/parse/")
      .build()
    );

And we use live query like this:

ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient();
ParseQuery<Message> parseQuery = ParseQuery.getQuery(Message.class);

SubscriptionHandling<ParseObject> subscriptionHandling = parseLiveQueryClient.subscribe(parseQuery)
subscriptionHandling.handleEvents(new SubscriptionHandling.HandleEventsCallback<ParseObject>() {
    @Override
    public void onEvents(ParseQuery<ParseObject> query, SubscriptionHandling.Event event, ParseObject object) {
        // HANDLING all events
    }
});

If you see we dont provide any url for live query. My question is what url live query use?

Our normal parse server is: http://server:1337/parse/
Does live query use same url but only change protocol to ws? Like this: ws://server:1337/parse/

What I mean is live query doesn’t change url but only uses different protocol right?

Well, I don’t use Android, so I won’t pretend to be an expert there, but from what I know from the other SDKs (iOS, Swift, and JS) they all seem to work the same in reference to your question above. So yes, since you are not supplying a specific LiveQuery URL, it will use your parse server one and upgrade it to a web socket for LiveQueries, ws://server:1337/parse/. And this will work if you enable the live query server on your parse server.

The docs I linked earlier mention that running a LiveQuery server on your Parse Server can cause a bottleneck depending on your application and provides some suggestions for scalability. If you end up using the docs suggestions, you will probably end up specifying a different LiveQuery server URL than your Parse Server URL.

1 Like