Picture of Sascha
Registered 5 years 281 days
Sascha Tuesday, 6 July 2021, 11:27 AM
Agenda SDK Dialog: Paging http request tasks
Hello everyone,

I hope this description will help you to understand what I want to do.

Scenarion:
I want to do http reuqests to the graph api for miscrosoft teams from a task in the app service which I'am building. The response from the graph api is json and I will get a maximum of 100 entries. I will get a next link in the json response from graph which I have to call to get the next 100 entries. If I got all the entries I won't find a next link in the json.
 
Problem:
When I start this task it will get the first 100 entries but as soon as the second request is send it will fail. This is because the destroy method from the first 100 entries also kills the second request which is in progress at that moment.
 
Structure:
I have set up this structure of files:

TaskHttpRequest
This tasks makes the request and gives me back the payload after the request is done
 
TaskGetTeamsUsers
This task initiates the TaskHttpRequest and uses the payload to read the json and create a representation of the users for us.
 
Now how can I spawn a new task from TaskGetTeamsUsers which gets the next entries from graph. I have tried the TaskProgress mehtod. But I run with this methode into the same problem as I have described it.

If you need more informations please ask!
Picture of Marc Schodermayr (innovaphone)
Moderator Registered 9 years 201 days
Marc Schodermayr (innovaphone) Tuesday, 6 July 2021, 11:56 AM
Re: Agenda SDK Dialog: Paging http request tasks
So I don't totally get it. What do you mean by "because the destroy method from the first 100 entries also kills the second request". Which destroy method?
Picture of Sascha
Registered 5 years 281 days
Sascha Tuesday, 6 July 2021, 03:36 PM
Re: Agenda SDK Dialog: Paging http request tasks
In the TaskHttpRequest there is a "~TaskHttpRequest()" which deletes the created httpClient after it was used.

I add this log from the application maybe it will help you to see the flow.

07-06 13:31:04.903 whoison@development01-199.de TaskHttpRequest::TaskHttpRequest: address='https://graph.microsoft.com' query='/v1.0/users?$top=10'
07-06 13:31:04.903 whoison@development01-199.de TaskGetTeamsUsers::TaskGetTeamsUsers
07-06 13:31:04.903 whoison@development01-199.de TaskHttpRequest::SetBearerToken: token=eyJ0eXAiOiJKV1QiLCJub25jZSI6IlBPQVc3LTBlQW9GWXExNXdIdHhq
07-06 13:31:04.903 whoison@development01-199.de TeamsUsersInit::TeamsUsersInit
07-06 13:31:04.903 whoison@development01-199.de TeamsUsersInit::Start
07-06 13:31:04.903 whoison@development01-199.de TaskGetTeamsUsers::Start
07-06 13:31:04.903 whoison@development01-199.de TaskHttpRequest::Start
07-06 13:31:04.904 whoison@development01-199.de TaskHttpRequest::~TaskHttpRequest
07-06 13:31:04.933 whoison@development01-199.de TaskHttpRequest::HTTPClientConnectComplete
07-06 13:31:05.051 whoison@development01-199.de TaskHttpRequest::HTTPClientSendResult
07-06 13:31:05.052 whoison@development01-199.de TaskHttpRequest::HTTPClientRequestComplete
07-06 13:31:05.052 whoison@development01-199.de TaskHttpRequest::HTTPClientRecvResult
07-06 13:31:05.053 whoison@development01-199.de TaskHttpRequest::HTTPClientRecvResult
07-06 13:31:05.053 whoison@development01-199.de TaskHttpRequest::HTTPClientRecvResult
07-06 13:31:05.054 whoison@development01-199.de TaskHttpRequest::HTTPClientRecvResult
07-06 13:31:05.054 whoison@development01-199.de TaskHttpRequest::HTTPClientShutdown http_shutdown_reason=0 payload={"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","@odata.nextLink":"https://graph.microsoft.com/v1.0/users?$top=10&$skiptoken=X%27445370740200010F736F66742E636F6D29557365725F36666130363962352D333436322D343731642D393730652D666630306462646535396434B900000000000000000000%27","value":[]}
07-06 13:31:05.055 whoison@development01-199.de TaskGetTeamsUsers::TaskComplete
07-06 13:31:05.055 whoison@development01-199.de TaskGetTeamsUsers::ParseTeamsUsers
07-06 13:31:05.055 whoison@development01-199.de TaskGetTeamsUsers::TaskProgress
07-06 13:31:05.055 whoison@development01-199.de TaskGetTeamsUsers:: progress - 0
07-06 13:31:05.055 whoison@development01-199.de TaskHttpRequest::TaskHttpRequest: address='https://graph.microsoft.com' query='/v1.0/users?$top=10&$skiptoken=X%2744537074020001000F736F66742E636F6D29557365725F36666130363962352D333436322D343731642D393730652D666630306462646535396434B900000000000000000000%27'
07-06 13:31:05.055 whoison@development01-199.de TaskHttpRequest::SetBearerToken: token=eyJ0eXAiOiJKV1QiLCJub25jZSI6IlBPQVc3LTBlQW9GWXExNXdIdHhqMGFldzRleGlq
07-06 13:31:05.055 whoison@development01-199.de TaskHttpRequest::Start
07-06 13:31:05.056 whoison@development01-199.de TaskHttpRequest::~TaskHttpRequest
07-06 13:31:05.056 ASSERT: Dns::~Dns responseCounter not 0, wait for DnsGetHostByNameResult missing? (~Dns:105)

In the end I get a Segmentation fault. This happens in this part of the log.
07-06 13:31:05.056 whoison@development01-199.de TaskHttpRequest::~TaskHttpRequest

Right after the the new request for the next entries is send. To test this I have changed it so that we will only get 10 users from the graph api.
Picture of Marc Schodermayr (innovaphone)
Moderator Registered 9 years 201 days
Marc Schodermayr (innovaphone) Thursday, 8 July 2021, 05:15 PM
Re: Agenda SDK Dialog: Paging http request tasks
As an addition to what Guntram said: you can reuse the HTTPClient instance by holding the instance outside of the Task you created and pass it as parameter to be used inside the task. Because if you delete the HTTPClient instance, the new request will be canceld (actually, it will go to nowhere, because the connection to the server will be kind of killed in that case).
2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Friday, 9 July 2021, 04:00 PM in response to Sascha
Re: Agenda SDK Dialog: Paging http request tasks
We had another look and it could be that you are deleting the httpclient object too early. You should wait for the UHTTPClient::HTTPClientShutdown callback
Could you check this?
Picture of Sascha
Registered 5 years 281 days
Sascha Monday, 12 July 2021, 08:55 AM
Re: Agenda SDK Dialog: Paging http request tasks
Yes I have found the problem. I did not create a new instance and this was the problem with the seg fault. Now it makes the requests.
2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Friday, 16 July 2021, 08:39 AM
Re: Agenda SDK Dialog: Paging http request tasks
Thanks, I will close this thread now
2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Thursday, 8 July 2021, 05:09 PM in response to Sascha
Re: Agenda SDK Dialog: Paging http request tasks
The classes TaskHttpRequest and TaskGetTeamsUsers is part of your code not part of our SDK somewhere, right?
With the API defined in http_client.h it the different HTTP requests are independent of each other, so I see no problem creating a new Task for the next request at any time.
Maybe you can post the code of these classes, so we can have a look and maybe understand the problem.
Picture of Sascha
Registered 5 years 281 days
Sascha Friday, 9 July 2021, 09:02 AM
Re: Agenda SDK Dialog: Paging http request tasks
Yes the classes TaskHttpRequest and TaskGetTeamsUsers are build by us and are not a part of the SDK.

I try to call a new TaskGetTeamsUsers as soon as the TaskGetTeamsUsers is complete with the parameters of the next link.


← You can define your color theme preference here