GitLabApiClient: LoginAsync waiting Infinitely
When I make a call to client.LoginAsync, the method never returns. The call in
var accessTokenResponse = await _requestor.Post<AccessTokenResponse>(url, accessTokenRequest);
in GitlabHttpFacade never returns.
Either my self hosted gitlab server blocked the API calls or some thing related to network happened , because my Client application using GitLabAPIClient was working fine until yesterday. Do you have any probable scenarios that may trigger this issue. In either case, the wait should do a timeout . Implemented Cancelation Token in POST request like below,
public async Task<T> Post<T>(string url, object data = null)
{
**var ct = new CancellationTokenSource();
ct.CancelAfter(3000);**
StringContent content = SerializeToString(data);
var responseMessage = await _client.PostAsync(url, content,ct.Token);
await EnsureSuccessStatusCode(responseMessage);
return await ReadResponse<T>(responseMessage);
}
it works, but not fits to the existing code flow. Since I am very new to this API, just getting used to the workflow. The timeout value can be set at GitlabClient level, but putting this cancellation token in all request, must be there a better way to do this.
But the Big question, Why the Gitlab not returning the request? tried both Private key method and then calling client.Project.getAsync() , and issue is same. Iam able to access the Gitlab through browser, restarted my gitlab instance, but still same issue.
Also, When i make a URL request in browser, it returns Jsons http://myserver/api/v4/projects
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (12 by maintainers)
Change your code to call from an async method so you can enjoy async/await code.