C#httpwebrequest 19号电话失败
奇怪的行为。至少是我所看到的。需要一些指导。这是我的调用序列:
httpWebRequest = (HttpWebRequest)WebRequest.Create(strURL.ToString());
httpWebRequest.Method = "GET";
strStatus = "Wait:GetResponse:" + pThreadName;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
using (WebResponse webResponse = httpWebRequest.GetResponse())
{
strStatus = "Wait:GetResponseStream:" + pThreadName; ;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null)
{
using (StreamReader responseReader = new StreamReader(webStream))
{
string strResponse = responseReader.ReadToEnd();
responseReader.Close();
// Get ID list from response.
Int32 intIndexOfProcessingids = -1;
intIndexOfProcessingids = strResponse.IndexOf("Processing");
if (intIndexOfProcessingids > -1)
{
strReturn = strResponse.Substring(intIndexOfProcessingids + 15).Replace(". \"]", string.Empty);
}
else
{
strReturn = string.Empty;
}
}
webResponse.Close();
}
httpWebRequest = null;
strStatus = "WebRequest:Closed:" + pThreadName;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
}
在多个服务器上调用RESTFUL API-尝试从单个服务器控制它 - 如果可以的话,请使用服务器Marshall。
我在5个不同的服务器上运行了5个API调用。因此,服务器1,API 1,Server 1,API 2 ...通过... Server 5,API 4,Server 5,API 5的组合。
我正在单个线程中运行每个API调用,4个线程在一个时间(试图不压倒我正在运行的服务器。)因此,它运行4个线程/4个API,然后一旦完成,另一个开始就开始。基本上是4个工作线程一次。同样,每个线程处理一个API。
我的问题是,我不能让它以18种以上的API运行。 (同样,我的测试床是5台服务器,各台5个API)。在第19个服务器/API组合中总是失败。服务器都配置了相同。我可以以不同的方式订购服务器,没关系。我可以按照任何顺序的19个不同时间运行一个工人线程,并且总是在19日失败。我正在循环这个,所以一旦一个线程完成,它将再次开始。但是从不适用于服务器/API组合> 18。从不。
在任务中尝试了相同的事情,而不是手动控制线程 - 相同的差异。 18个任务有效。大约是第19次。总是失败。
当我说它失败时,它是在其余API上的时间。我遇到了500个错误 - 我的SQL Server正在从REST API中的呼叫中计时。
有什么想法吗?一台计算机对HTTP请求有任何限制吗?不知道从这里去哪里。
谢谢。
m
Odd behavior. At least for what I've seen. Need some guidance. Here's my calling sequence:
httpWebRequest = (HttpWebRequest)WebRequest.Create(strURL.ToString());
httpWebRequest.Method = "GET";
strStatus = "Wait:GetResponse:" + pThreadName;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
using (WebResponse webResponse = httpWebRequest.GetResponse())
{
strStatus = "Wait:GetResponseStream:" + pThreadName; ;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null)
{
using (StreamReader responseReader = new StreamReader(webStream))
{
string strResponse = responseReader.ReadToEnd();
responseReader.Close();
// Get ID list from response.
Int32 intIndexOfProcessingids = -1;
intIndexOfProcessingids = strResponse.IndexOf("Processing");
if (intIndexOfProcessingids > -1)
{
strReturn = strResponse.Substring(intIndexOfProcessingids + 15).Replace(". \"]", string.Empty);
}
else
{
strReturn = string.Empty;
}
}
webResponse.Close();
}
httpWebRequest = null;
strStatus = "WebRequest:Closed:" + pThreadName;
mUpdateServerListCallBack(pServerID, pServerName, pServerInstance, strStatus);
}
Calling Restful APIs on multiple servers - Trying to control it from a single server - a server marshall if you will.
I've got 5 API calls running across 5 different servers. So, combination of Server 1, API 1, Server 1, API 2 ... through ... Server 5, API 4, Server 5, API 5.
I'm running each API call within a single thread, 4 threads at a time (Was trying not to overwhelm the server I'm running this on.) So it runs 4 threads/4 APIS, then once one finishes, another one begins. Basically 4 worker threads running at a time. Again, each thread processing one API.
My problem is, I can't get this to run for more than 18 different APIs. (Again, my test bed is 5 servers, 5 APIs each). Always fails on the 19th Server/API combination. Servers are all configured the same. I can order the servers differently, doesn't matter. I can run this with a single worker thread, in any order, 19 different times, and it ALWAYS fails on the 19th. I'm looping this, so once one thread finishes, it kicks off again. But never works for the server/API combos > 18. Never.
Tried the same thing with tasks, instead of manually controlling the threads - same difference. 18 tasks work. Something about the 19th time. Always fails.
When I say it fails, it's timing out on the Rest API. I get a 500 error - my SQL Server is timing out from calls within the Rest API.
Any thoughts? Any limitations on http requests from a single machine? No idea where to go from here.
Thanks.
m
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论