You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just updated my application to 18.6.0 (via NuGet, if that matters) and discovered a weird behavior of new ReportUtilities: it successfully gets two reports for the same client, but requesting a third one will just hang until timeout. Switching back to legacy ReportUtilities works fine.
Here's some test code.
It requests 3 exactly the same reports (for simplicity, reproduces for different reports too) in a row, showing the first two are returned in a few seconds, but 3rd one always timeouts after 100 seconds (default timeout in app.config). Increasing the timeout value doesn't help, just makes it stuck for more time.
using System;using System.Xml;using System.Diagnostics;using Google.Api.Ads.Common.Lib;using Google.Api.Ads.AdWords.Lib;using Google.Api.Ads.AdWords.v201409;namespacetest_report{classProgram{staticvoidMain(string[]args){varadwords=new AdWordsUser();varconfig=(AdWordsAppConfig)adwords.Config;
config.Email ="...";
config.DeveloperToken ="...";
config.OAuth2Mode = OAuth2Flow.APPLICATION;
config.OAuth2RefreshToken ="...";
config.OAuth2ClientId ="...";
config.OAuth2ClientSecret ="...";
config.ClientCustomerId ="...";conststringReportVersion="v201409";DateTimestartDate=new DateTime(2014,10,1),endDate=new DateTime(2014,10,31);for(inti=1;i <= 3;i++){
Console.WriteLine("Report #{0}...", i);vardefi=new ReportDefinition();
defi.dateRangeType = ReportDefinitionDateRangeType.CUSTOM_DATE;
defi.reportType = ReportDefinitionReportType.KEYWORDS_PERFORMANCE_REPORT;
defi.reportName ="KEYWORDS_PERFORMANCE_REPORT";
defi.downloadFormat = DownloadFormat.XML;
defi.selector =new Selector(){fields=newstring[]{"CampaignId","CampaignName","Id","KeywordText","Date","Impressions","Clicks","Cost","AdNetworkType1"},dateRange=new DateRange
{min= startDate.ToString("yyyyMMdd"),max= endDate.ToString("yyyyMMdd")}};varstopwatch=new Stopwatch();
stopwatch.Start();try{// this works for first two reports and always fails for the 3rd one:varutil=new Google.Api.Ads.AdWords.Util.Reports.ReportUtilities(adwords, ReportVersion, defi);varresponse= util.GetResponse();varxml=new XmlDocument();
xml.Load(response.Stream);// and this works okay://var util = new Google.Api.Ads.AdWords.Util.Reports.Legacy.ReportUtilities(adwords);//util.ReportVersion = ReportVersion;//var response = util.GetClientReport(defi);//var xml = new XmlDocument();//xml.LoadXml(response.Text);
stopwatch.Stop();
Console.WriteLine("Done in {0}", stopwatch.Elapsed);}catch(Exceptionex){
stopwatch.Stop();
Console.WriteLine("Error in {0}: {1}", stopwatch.Elapsed, ex.Message);}}}}}
The output is:
Report #1...
Done in 00:00:04.3187831
Report #2...
Done in 00:00:02.8653650
Report #3...
Error in 00:01:40.0315389: The operation has timed out
The text was updated successfully, but these errors were encountered:
ReportResponse is a disposable object, which wraps the underlying WebRequest and WebResponse. Unless it is disposed, .NET won't open more connections. The magical number "3" comes from ServicePointManager.DefaultConnectionLimit Property, which is 2.
Try modifying your code to:
using(ReportResponseresponse= util.GetResponse()){varxml=new XmlDocument();
xml.Load(response.Stream);
stopwatch.Stop();
Console.WriteLine("Done in {0}", stopwatch.Elapsed);}
Hello.
I've just updated my application to 18.6.0 (via NuGet, if that matters) and discovered a weird behavior of new ReportUtilities: it successfully gets two reports for the same client, but requesting a third one will just hang until timeout. Switching back to legacy ReportUtilities works fine.
Here's some test code.
It requests 3 exactly the same reports (for simplicity, reproduces for different reports too) in a row, showing the first two are returned in a few seconds, but 3rd one always timeouts after 100 seconds (default timeout in app.config). Increasing the timeout value doesn't help, just makes it stuck for more time.
The output is:
The text was updated successfully, but these errors were encountered: