Skip to content

live error #196

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
unreal0 opened this issue Jun 15, 2019 · 9 comments
Closed

live error #196

unreal0 opened this issue Jun 15, 2019 · 9 comments

Comments

@unreal0
Copy link

unreal0 commented Jun 15, 2019

*** error info ***
I/flutter (12537): LiveQuery: : ConnectMessage: {op: connect, applicationId: myAppId, masterKey: 123456, sessionToken: null}
I/flutter (12537): LiveQuery: : SubscribeMessage: {op: subscribe, requestId: 1, query: {className: Diet_Plans, where: {objectId: 2pNUgv1CKA}}, sessionToken: null}
I/flutter (12537): LiveQuery: : Listen: {"op":"error","error":"Invalid type: null (expected string)","code":1,"reconnect":true}
*** server log info***
2019-06-15T16:11:53.624Z - Connect message error Invalid type: null (expected string) 2019-06-15T16:11:53.623Z - Connect message error Invalid type: null (expected string) 2019-06-15T16:11:50.911Z - Can not find client undefined on disconnect 2019-06-15T16:11:35.270Z - Connect message error Invalid type: null (expected string) 2019-06-15T16:11:35.268Z - Connect message error Invalid type: null (expected string) 2019-06-15T16:11:32.126Z - Can not find client undefined on disconnect 2019-06-15T16:11:32.125Z - Client disconnect: undefined

code
`Future initData() async {

// Initialize parse
Parse().initialize(
  keyParseApplicationId,
  keyParseServerUrl,
  masterKey: keyParseMasterKey,
  debug: true,
  liveQueryUrl: keyParseLiveServerUrl,
);


final ParseResponse response = await Parse().healthCheck();

if (response.success) {
  await _listen();
}

}`

`Future _listen() async {
QueryBuilder query = QueryBuilder(DietPlan())
..whereEqualTo('objectId', '2pNUgv1CKA');
LiveQuery liveQuery = LiveQuery();
// print("=====query: $query");
await liveQuery.subscribe(query);

liveQuery.on(LiveQueryEvent.update, (dynamic value) {
  

  print('*** UPDATE ***: ${DateTime.now().toString()}\n $value');
  print((value as ParseObject).objectId);
  print((value as ParseObject).updatedAt);
  print((value as ParseObject).createdAt);
  // print((value as ParseObject).get('objectId'));
  // print((value as ParseObject).get('updatedAt'));
  // print((value as ParseObject).get('createdAt'));

  print("data:" + (value as ParseObject).toJson().toString());
  // _result.add(value);
});

}`

@phillwiggins
Copy link
Member

phillwiggins commented Jun 15, 2019 via email

@unreal0
Copy link
Author

unreal0 commented Jun 16, 2019

no effect

parse server v2.7.1
parse dashboard v1.2

parse live config:
liveQuery: {
classNames: ["Diet_Plans","Item","post", "comments"]
},

@yulingtianxia
Copy link
Contributor

@unreal0 Just set autoSendSessionId to true in Parse.initialize.

@unreal0
Copy link
Author

unreal0 commented Jun 16, 2019

websoket ok!!! thanks
a pair :
sessionId: "1212121", autoSendSessionId: true,

Parse().initialize(keyParseApplicationId, keyParseServerUrl, masterKey: keyParseMasterKey, liveQueryUrl: keyParseServerUrl, // clientKey: "XXXi3GejX3SIxpDgSbKHHV8uHUUP3QGiPPTlxxxx", sessionId: "1212121", autoSendSessionId: true, debug: true);
server log
2019-06-16T13:16:56.506Z - Create new client: 75988d97-6690-4460-8c95-689da3c249a1

flutter log
I/flutter ( 4405): LiveQuery: : Listen: {"op":"subscribed","clientId":"75988d97-6690-4460-8c95-689da3c249a1","requestId":1}
I/flutter ( 4405): data changed:{className: Diet_Plans, objectId: 3CHGfVoR0t, createdAt: 2019-06-16T13:14:44.935Z, updatedAt: 2019-06-16T13:17:01.358Z, Name: LawFolk, Description: High quality fats, low carbs., Fat: 65, Carbs: 5, Protein: 30, Status: 0}

@zenz
Copy link
Contributor

zenz commented Jun 17, 2019

If you don't want to send session id while init the Parse SDK, you can send it during init LiveQuery instance.

@RodrigoSMarques
Copy link
Contributor

@zenz
Sending the session is optional and this is defined in the code:

       _sendSessionId = autoSendSessionId ?? ParseCoreData().autoSendSessionId;
      .....
      //The connect message is sent from a client to the LiveQuery server.
      //It should be the first message sent from a client after the WebSocket connection is established.
      _connectMessage = <String, String>{
        'op': 'connect',
        'applicationId': _client.data.applicationId,
        'clientKey': _client.data.clientKey ?? ''
      };
      if (_sendSessionId) {
        _connectMessage['sessionToken'] = _client.data.sessionId;
      }

@unreal0
Copy link
Author

unreal0 commented Jun 17, 2019

how to config bloc connect to live stream?

@git-elliot
Copy link

git-elliot commented Aug 19, 2019

Make sure your initialization code completes before performing any request to the server. Execute live query code in "then"
Here is the code snippet which resolved my problem.

await Parse().initialize(
        AppConstants.applicationId,
        AppConstants.parseServerUrl,
        clientKey: AppConstants.parseClientKey,
        debug: true, 
        liveQueryUrl: AppConstants.parseServerUrl,
        autoSendSessionId: false,
		    coreStore: await CoreStoreSembastImp.getInstance()
        ).then((value){
            subscribe(); // all live query code go here
        });

@phillwiggins
Copy link
Member

There's not been much movement on this recently. Are we safe to close?

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

Successfully merging a pull request may close this issue.

6 participants