开发者

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

开发者 https://www.devze.com 2023-03-08 15:15 出处:网络
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 mat

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

精彩评论

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