It's not an open source project. I am just trying to integrate Tinode in my existing project. Almost everything is done already, except I can't get the number of unread messages of users. But it very important.
Probably the problem is the following. After each GRPC request I see the following message on the server:
E2021/03/15 10:23:35 grpc: recv sxNwJc_UgJ0 rpc error: code = Canceled desc = context canceled
I have googled for it but didn't find any solution. Generally, this error does not affect anything and I get responses from the server. There are problems only with sub and get requests. sub request returns just one message {"id":"552815","topic":"me","code":200,"text":"ok"} and nothing more. Probably it's because of this error and connection closes.
But it doesn't explain why I don't get any response to the get request because get request should return only one message but I don't get anything. Yes, it returns but only in a case of invalid request. For example, if I send a get request without what, Tinode returns error:
Server log:
I2021/03/15 10:39:49 grpc in: get:<id:"975419" topic:"me" > on_behalf_of:"usrHGshCFWe5aI" BhWWZOFpWvQ
W2021/03/15 10:39:49 s.get: invalid Get message action
E2021/03/15 10:39:49 grpc: recv BhWWZOFpWvQ rpc error: code = Canceled desc = context canceled
Response:
{"id":"975419","topic":"me","code":400,"text":"malformed"}
However, if I send a valid request, Tinode does not return absolutely anything and there are no errors on the server:
Server log:
I2021/03/15 10:46:01 grpc in: get:<id:"315201" topic:"me" query:<what:"sub" > > on_behalf_of:"usrHGshCFWe5aI" OF6yIcVT8Ck
E2021/03/15 10:46:01 grpc: recv OF6yIcVT8Ck rpc error: code = Canceled desc = context canceled
Response
empty
I also can not understand some things in the
documentation about
get request. It says that
what should not be a part of of
sub:
get: {
id: "1a2b3", // string, client-provided message id, optional
topic: "grp1XUtEhjv6HND", // string, name of topic to request data from
//why to inslude "topic" twice?
what: "sub desc data del cred", // string, space-separated list of parameters to query;
.....
.....
// Optional parameters for {get what="sub"}
sub: {
ims: "2015-10-06T18:07:30.038Z", // timestamp, "if modified since" - return
// public and private values only if at least one of them has been
// updated after the stated timestamp, optional
user: "usr2il9suCbuko", // string, return results for a single user,
// any topic other than 'me', optional
topic: "usr2il9suCbuko", // string, return results for a single topic,
// 'me' topic only, optional
//why to inslude "topic" twice? If only for "me"topic, why the value in the example is "usr2il9suCbuko" and not "me"?
limit: 20 // integer, limit the number of returned objects
},
.....
.....
.......
So, according to the documentation, get request should look like this:
I2021/03/15 11:13:00 grpc in: get:<id:"877216" topic:"me" what:"sub" > > on_behalf_of:"usrHGshCFWe5aI" Q8SHxyIjcjo
but as I wrote, I automatically generated php classes from Tinode's proto file and according to the generated classes what should be a part of sub
I2021/03/15 11:13:00 grpc in: get:<id:"877216" topic:"me" query:<what:"sub" > > on_behalf_of:"usrHGshCFWe5aI" Q8SHxyIjcjo
I don't know, probably there is some error in proto file. All the php classes that need to send what contains 2 functions: getWhat(); and setWhat(); Class ClientGet does not contain it and that's why I underestand that what should be a part of sub.
How exactly should look get request to get the number of unread messages for an user?
Is there another way to get the number of unread messages for a user? I could query directly the database but it does not contain real values in recvseqid and readseqid. As I understand the data updates from time to time and the values are not real.
Suggestion: please make a new client to server message, something like:
unread: {
id: "1a2b3",
topic: "me",
user: "usr..."
}
with response something like this:
{"id":"
1a2b3 ","unread":17}
that only will return the number of unread messages. Even if --get-query sub would work with GRPC, it returns a huge amount of useless data that needs to be processed just to get one number - the amount of unread messages. As I see in the forums, I am not the only person who needs it. And it's a very important thing to integrate Tinode in an existing project.