Time outs after X successful calls.

20 views
Skip to first unread message

caseyy

unread,
May 16, 2008, 4:17:04โ€ฏPM5/16/08
to AdWords API Forum
I am trying to get Daily URL reports. I can do about 1 to 3 back to
back with 90 sec between jobs, then after those successful calls, I
start getting "The operation has timed out." exceptions when it is
trying to call validateReportJob(). I am using c#, .net 2.0, and have
inherted the class to a "safety" class that sets KeepAlive to false.
I have been getting this with more than just the ReportService. I get
the same strange error with Updating bids. What seems the cause of
this? Funny thing is, when it starts timing out, it can last 1 to
100+ calls of consecutive time outs, but if I quit the application and
restart it, it goes 1 to 3 more then starts timing out again.

Peer Jakobsen

unread,
May 16, 2008, 7:48:00โ€ฏPM5/16/08
to AdWords API Forum
Hi,

You might wan't to try to set the Expect100Continue to false in your
base class. Like this:

Protected Overrides Function GetWebRequest(ByVal Uri As Uri) As
WebRequest
System.Net.ServicePointManager.Expect100Continue = False
Dim webRequest As HttpWebRequest =
CType(MyBase.GetWebRequest(Uri), HttpWebRequest)
webRequest.KeepAlive = False
Return webRequest
End Function

caseyy

unread,
May 19, 2008, 10:43:05โ€ฏAM5/19/08
to AdWords API Forum
This didn't work... After about 4 successful, it started to fail
again when validating the reportjob.

Any other ideas to try?

AdWords API Advisor

unread,
May 19, 2008, 12:51:41โ€ฏPM5/19/08
to AdWords API Forum
Hello Casey,

I can't find the default value for .NET 2.0 documented anywhere but
it should be long enough for a normal validateReportJob() request to
complete and return a result. You could raise the value by adjusting
the Timeout property to something like a minute:

http://msdn.microsoft.com/en-us/library/system.net.webrequest.timeout(VS.80).aspx

but again, it really shouldn't take that long for your requests to
complete. Do the reports your validating include a very large number
of campaigns or accounts?

Cheers,
-Jeff Posnick, AdWords API Team

caseyy

unread,
May 19, 2008, 2:01:47โ€ฏPM5/19/08
to AdWords API Forum
I have tried setting the default timeout as well. All it did was make
it wait for time out a lot longer. These reports don't have that
much. Like I said, it works fine and speedy if I stop my application
and restart it. It is just after 2 or 3 in a row within 1 instance of
my application, the calls just start to time out, no matter what
length I set the timeout value of the request.

On May 19, 11:51 am, AdWords API Advisor
<adwordsapiadvi...@google.com> wrote:
> Hello Casey,
>
> I can't find the default value for .NET 2.0 documented anywhere but
> it should be long enough for a normal validateReportJob() request to
> complete and return a result. You could raise the value by adjusting
> the Timeout property to something like a minute:
>
> http://msdn.microsoft.com/en-us/library/system.net.webrequest.timeout...

AdWords API Advisor

unread,
May 20, 2008, 12:12:15โ€ฏPM5/20/08
to AdWords API Forum
Hello Casey,

Well, to state the obvious, if whether the call completes quickly or
slowly is determined by how recently you've started your application,
then it would imply that there may be something going on application-
side causing it. Can you reproduce this behavior in a simple
application, like the example that ships with the client library?

http://code.google.com/p/google-api-adwords-dotnet/source/browse/trunk/Examples/src/ReportServiceKeywordDemo.cs

Cheers,
-Jeff Posnick, AdWords API Team


caseyy

unread,
May 20, 2008, 2:13:46โ€ฏPM5/20/08
to AdWords API Forum
I'm using the same code as that example, just grabbing a URL report.
And instead of just 1 report, I have a foreach loop to grab say 10
reports, 1 after the other. Each report is the same report, but
different google username/pass. That is the only modification I have
done to that example.

Casey

On May 20, 11:12 am, AdWords API Advisor
<adwordsapiadvi...@google.com> wrote:
> Hello Casey,
>
> Well, to state the obvious, if whether the call completes quickly or
> slowly is determined by how recently you've started your application,
> then it would imply that there may be something going on application-
> side causing it. Can you reproduce this behavior in a simple
> application, like the example that ships with the client library?
>
> http://code.google.com/p/google-api-adwords-dotnet/source/browse/trun...

AdWords API Advisor

unread,
May 20, 2008, 4:30:14โ€ฏPM5/20/08
to AdWords API Forum
Could you post exactly what your modified code looks like (with the
usernames/passwords X-ed out)?

Cheers,
-Jeff Posnick, AdWords API Team


caseyy

unread,
May 20, 2008, 4:45:48โ€ฏPM5/20/08
to AdWords API Forum
private XmlDocument GetGoogleReport(long id, string email, string
password, DateTime startDate, DateTime endDate)
{
Console.WriteLine("Enter GetGoogleReport");
XmlDocument xDoc = new XmlDocument();

SafeReportService service = new SafeReportService();

service.emailValue = new email();
service.emailValue.Text = new String[] { email };
service.passwordValue = new password();
service.passwordValue.Text = new String[] { password };
service.clientEmailValue = new clientEmail();
service.clientEmailValue.Text = new String[] { email };
service.useragentValue = new useragent();
service.useragentValue.Text = new String[] { "XXXXXXX: Get Daily Url
Reports" };
service.developerTokenValue = new developerToken();
service.developerTokenValue.Text = new String[]
{ Constants.GoogleDeveloperTokenValue };
service.applicationTokenValue = new applicationToken();
service.applicationTokenValue.Text = new String[]
{ Constants.GoogleApplicationTokenValue };

// Create report job structure.
Console.WriteLine("Create Job");
DefinedReportJob job = new DefinedReportJob();
job.selectedReportType = "Url";
job.name = "Daily Url Report";
job.aggregationTypes = new String[] { "Daily" };
job.adWordsType = AdWordsType.SearchOnly;
job.keywordType = KeywordType.Broad;
job.startDay = new DateTime();
job.startDay = startDate;
job.endDay = new DateTime();
job.endDay = endDate;
job.selectedColumns = new String[]
{
"Campaign", "AdGroup", "DestinationURL", "MaximumCPC",
"MaxContentCPC", "Impressions", "Clicks", "CTR",
"Cost"
};

// Validate report.
try
{
Console.WriteLine("Validate Job");

service.validateReportJob(job);

Thread.Sleep(15000);
// Schedule report.
Console.WriteLine("Get Job Id");
long jobId = service.scheduleReportJob(job);
Thread.Sleep(15000);

// Wait for report to finish.
Console.WriteLine("Get Status");
ReportJobStatus status = service.getReportJobStatus(jobId);
while (status != ReportJobStatus.Completed && status !=
ReportJobStatus.Failed)
{
Console.WriteLine("Report job status is \"" + status + "\".");
Thread.Sleep(30000);
status = service.getReportJobStatus(jobId);
}

if (status == ReportJobStatus.Failed)
{
Console.WriteLine("Report job generation failed.");
Logger.WriteLog("Report job generation failed.",
EventLogEntryType.Error);
return null;
}

// Download report.
Thread.Sleep(15000);
String url = service.getGzipReportDownloadUrl(jobId);
Console.WriteLine("Report is available at \"" + url + "\".");

service.Dispose();

// get the file
Console.WriteLine("Get job File");
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
HttpWebResponse webResponse = (HttpWebResponse)
webRequest.GetResponse();

GZipStream zipStream = new
GZipStream(webResponse.GetResponseStream(),
CompressionMode.Decompress);

byte[] buffer = new byte[2048];
MemoryStream memoryStream = new MemoryStream();

while (true)
{
int read = zipStream.Read(buffer, 0, buffer.Length);
if (read <= 0) break;
memoryStream.Write(buffer, 0, read);
}
memoryStream.Position = 0;

Console.WriteLine("Load To XML");
xDoc.Load(memoryStream);
}
catch (Exception ex2)
{
Console.WriteLine("Report job failed validation due to the following
error: \"" + ex2.Message + "\".");
Logger.WriteLog("Report job failed validation due to the following
error: \"" + ex2.Message + "\".", EventLogEntryType.Warning);
}

return xDoc;
}

*****************************************************************************************************

using System;
using System.Net;

namespace GetGoogleReports
{
public class SafeReportService : Google.ReportService.ReportService
{
protected override WebRequest GetWebRequest(Uri uri)
{
ServicePointManager.Expect100Continue = false;
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
return request;
}
}
}



On May 20, 3:30 pm, AdWords API Advisor <adwordsapiadvi...@google.com>

AdWords API Advisor

unread,
May 27, 2008, 4:42:13โ€ฏPM5/27/08
to AdWords API Forum
Well, I unfortunately don't see anything obviously amiss in the code
you posted. And that code is call in a loop multiple times? Is there a
pause because each method call to GetGoogleReport()?

Unless someone else in the group has any ideas I guess it might be
worthwhile to try doing some debugging at the network level, i.e.
running NetMon or Wireshark on the machine running your code to see if
the HTTPS request is successfully sent and acknowledged and whether
there's any sort of response from the server at all.

Cheers,
-Jeff Posnick, AdWords API Team


caseyy

unread,
May 28, 2008, 10:11:46โ€ฏAM5/28/08
to AdWords API Forum
Yes, it is in a loop, and after each call of GetGoogleReports, I sleep
for 90 seconds. I will see if I can get a hold of some packet tools
and see what is going on the network level... Right now I have a crude
work around that is working in the meantime. I am just calling it 1
time, then letting the app exit. I have that setup in a scheduled
task to run every 2 min. It works good so far, but I would like to
take this application and make a service out of it.

On May 27, 3:42 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
> ...
>
> read more ยป
Reply all
Reply to author
Forward
0 new messages