开发者

Intermittant Repeated Timeouts from WebRequest.GetResponse connecting to Jenkins/Hudson

I am kicking off parameterized Jenkins builds from a c# application.

The urls are valid (I can pull it from the log and run it with no issue). At certain points all webrequests will time out, no matter how much the timeout is set for (i've gone up to 90 seconds) or how many times it is run.

This is intermittant and certain times, I will have no issues at all.

while (count<5)           
 { try{
                    log.WriteEntry("RunningJenkinsBuild- buildURL=" + buildUrl, EventLogEntryType.Information);
                    WebRequest request = WebRequest.Create(buildUrl);
    开发者_如何转开发                request.GetResponse();
                    return;
                }
                catch (WebException ex)
                {
                    log.WriteEntry("Timeout- wait 15 seconds and try again-"+ex.Message, EventLogEntryType.Error);
                    Thread.Sleep(15000);
                    count++;
                }
                catch (Exception ex2)
                {
                    log.WriteEntry(ex2.Message, EventLogEntryType.Error);
                    return;
                }
            }


This cleared it up. 'Using' helped it out.

WebRequest request = WebRequest.Create(buildUrl); request.Timeout = 10000; using (WebResponse response = request.GetResponse()) { } Thread.Sleep(5000);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜