Skip to content

Livequery is not firing any event #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yanuarizalk opened this issue Mar 18, 2021 · 4 comments
Closed

Livequery is not firing any event #582

yanuarizalk opened this issue Mar 18, 2021 · 4 comments

Comments

@yanuarizalk
Copy link

yanuarizalk commented Mar 18, 2021

Hi, i got trouble with my LiveQuery that didn't fire any event.
I've been following the instruction as the documentation said.

Env

Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (8 weeks ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5

Parse Server: 'parseplatform/parse-server:latest' (Docker)
Parse Flutter SDK: 2.1 (Latest as i write this issue)

Tried to:

  • Query manual using QueryBuilder & it does work (have value).
  • Changing the queried row via dashboard & server side.
  • Changing both version of server & client sdk to outdated version.

Server Config

{
    "allowClientClassCreation": false,
    "startLiveQueryServer": true,
    "liveQuery": {
        "classNames": [
            "Chat"
        ]
    },
    "maxUploadSize": "10mb",
    "logLevel": "error"
}

Code

var serverUrl = "http://${env['CHANNEL_HOST']}:${env['CHANNEL_PORT']}/parse/";
await Parse().initialize(
  env['APP_NAME'], serverUrl,
  debug: true,
  liveQueryUrl:  serverUrl,
  autoSendSessionId: true,
  clientKey: env['CHANNEL_KEY'],

);
Parse().healthCheck();

var user = ParseUser(_user.username, _user.parsePassword, _user.email, debug: true);
await user.login();

LiveQuery lq = LiveQuery(debug: true);
QueryBuilder query;
Subscription subscription;

query = QueryBuilder(ParseObject('Chat'))..whereEqualTo('u', 'H9OQSTFoCM');
Logger().d(['channelStart', (await query.object.getAll()).result]);
subscription = await lq.client.subscribe(query);
subscription.on(LiveQueryEvent.create, (value) {
  Logger().d(['LQ fire create', value]);
});
subscription.on(LiveQueryEvent.update, (value) {
  Logger().d(['LQ fire update', value]);
});
subscription.on(LiveQueryEvent.error, (value) {
  Logger().d(['LQ fire error', value]);
});
subscription.on(LiveQueryEvent.delete, (value) {
  Logger().d(['LQ fire delete', value]);
});
subscription.on(LiveQueryEvent.enter, (value) {
  Logger().d(['LQ fire enter', value]);
});
subscription.on(LiveQueryEvent.leave, (value) {
  Logger().d(['LQ fire leave', value]);
});

Log

I/flutter (11358): ╭-- Parse Request
I/flutter (11358): curl -X GET -H 'user-agent: Flutter Parse SDK 2.1.0' -H 'X-Parse-Application-Id: chitchat' -H 'X-Parse-Client-Key: walktothemordor' http://192.168.100.106:1337/parse/health
I/flutter (11358):
I/flutter (11358): http://192.168.100.106:1337/parse/health
I/flutter (11358): ╰--
I/flutter (11358): ╭-- Parse Response
I/flutter (11358): Class: parseBase
I/flutter (11358): Function: ParseApiRQ.healthCheck
I/flutter (11358): Status Code: 200
I/flutter (11358): Reponse: OK
I/flutter (11358): ╰--

I/flutter (32201): ╭-- Parse Response
I/flutter (32201): Class: _User
I/flutter (32201): Function: ParseApiRQ.login
I/flutter (32201): Status Code: 200
I/flutter (32201): Payload: {"className":"_User","objectId":"H9OQSTFoCM","createdAt":"2021-03-16T10:58:25.898Z","updatedAt":"2021-03-18T09:40:56.559Z","username":"lord_rizael1","email":"[email protected]","emailVerified":true,"personalId":{"__type":"Pointer","className":"Chat","objectId":"hHAC0XvcGT"},"ACL":{"H9OQSTFoCM":{"read":true,"write":true}},"sessionToken":"r:3bdb26c428dae4b348c968853267ba0e"}
I/flutter (32201): ╰--
I/flutter (32201):

I/flutter (11358): LiveQuery: : Socket opened
I/flutter (11358): LiveQuery: : ConnectMessage: {op: connect, applicationId: chitchat, clientKey: walktothemordor}
I/flutter (11358): LiveQuery: : Listen: {"op":"connected","clientId":"e40bacd0-a17b-4272-be70-ab082b996180"}
I/flutter (11358): ReSubScription:{}
I/flutter (11358): LiveQueryReconnectingController: LiveQueryClientEvent.CONNECTED
I/flutter (11358):
I/flutter (11358): ╭-- Parse Response
I/flutter (11358): Class: Chat
I/flutter (11358): Function: ParseApiRQ.getAll
I/flutter (11358): Status Code: 200
I/flutter (11358): Payload: [{"className":"Chat","objectId":"hHAC0XvcGT","createdAt":"2021-03-16T10:58:25.989Z","updatedAt":"2021-03-18T12:27:24.508Z","u":"H9OQSTFoCM","ls":{"__type":"Date","iso":"2021-03-17T17:58:00.000Z"},"s":{"b":"babo"},"r":{},"ACL":{"H9OQSTFoCM":{"read":true,"write":true}}}]
I/flutter (11358): ╰--

I/flutter (11358): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (11358): │ #0 MessageListController.channelStart (package:curak_id/app/modules/message_list/controllers/message_list_controller.dart:78:14)
I/flutter (11358): │ #1
I/flutter (11358): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (11358): │ 🐛 [
I/flutter (11358): │ 🐛 "channelStart",
I/flutter (11358): │ 🐛 [
I/flutter (11358): │ 🐛 {
I/flutter (11358): │ 🐛 "className": "Chat",
I/flutter (11358): │ 🐛 "objectId": "hHAC0XvcGT",
I/flutter (11358): │ 🐛 "createdAt": "2021-03-16T10:58:25.989Z",
I/flutter (11358): │ 🐛 "updatedAt": "2021-03-18T12:27:24.508Z",
I/flutter (11358): │ 🐛 "u": "H9OQSTFoCM",
I/flutter (11358): │ 🐛 "ls": {
I/flutter (11358): │ 🐛 "__type": "Date",
I/flutter (11358): │ 🐛 "iso": "2021-03-17T17:58:00.000Z"
I/flutter (11358): │ 🐛 },
I/flutter (11358): │ 🐛 "s": {
I/flutter (11358): │ 🐛 "b": "babo"
I/flutter (11358): │ 🐛 },
I/flutter (11358): │ 🐛 "r": {},
I/flutter (11358): │ 🐛 "ACL": {
I/flutter (11358): │ 🐛 "H9OQSTFoCM": {
I/flutter (11358): │ 🐛 "read": true,
I/flutter (11358): │ 🐛 "write": true
I/flutter (11358): │ 🐛 }
I/flutter (11358): │ 🐛 }
I/flutter (11358): │ 🐛 }
I/flutter (11358): │ 🐛 ]
I/flutter (11358): │ 🐛 ]
I/flutter (11358): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

I/flutter (11358): LiveQuery: : SubscribeMessage: {op: subscribe, requestId: 1, query: {className: Chat, where: {u: H9OQSTFoCM}}, sessionToken: r:f6591bf7e01d2512604a25a5a8504bda}
I/flutter (11358): LiveQuery: : Listen: {"op":"subscribed","clientId":"e40bacd0-a17b-4272-be70-ab082b996180","requestId":1}

Thanks

@yanuarizalk
Copy link
Author

Turn out that i need to open the ACL of queried row to public, although i've logged in with authenticated user.
It's normal to ParseQuery using authentic account, but not when using LiveQuery.

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Mar 20, 2021

@yanuarizalk
try to launch Livequery without sending the sessionId

SECURITY WITH LIVEQUERY

LiveQuery lq = LiveQuery(debug: true, autoSendSessionId: false);

@yanuarizalk
Copy link
Author

@yanuarizalk
try to launch Livequery without sending the sessionId

SECURITY WITH LIVEQUERY

LiveQuery lq = LiveQuery(debug: true, autoSendSessionId: false);

Thank you for your reply @RodrigoSMarques.
Just tested it now, still same.

@yanuarizalk
Copy link
Author

Look like it's not plugin issue, because when i try to duplicate same issue with other sdk (Javascript), the outcome still same. I can't bypass the ACL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants