- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 C# 应用程序,旨在使用线程在我的服务器中发出 http post 请求。 (这是为了简化问题,因为事实上,有几个不同的trheads在不同的URI上发出请求)
事实证明,这些踏板被设置为在不同的时间段提出请求。但我在我的服务器上检测到洪水,总是来自相同的 ip 并以巨大的序列出现,但事实并非如此。 - 这就像 DDoS 攻击!事实上,我的服务器在处理它时遇到了严重的问题。
我个人并不认为这是一次攻击,而是认为我分发给数千个客户的 C# 应用程序可能出了问题。大约10,000。那么每天最多会产生 10K 个请求。但事实上还有更多...
我的服务器使用 Python。
下面,我粘贴了一个发出这些请求的代码示例。我正在解释这一切并显示代码,希望有人能看到我看不到的东西。如果您发现错误,请提供帮助,我们将不胜感激。
DateTime nextCheck= DateTime.Now;
void checkLicenses()
{
// 5 minutes
autoResetEvent.WaitOne(300000, true);
while (this.ServiceAlive)
{
if (DateTime.Now < nextCheck)
{
autoResetEvent.WaitOne(30000, true);
continue;
}
if (this.InternetIsOk)
{
Monitor.Record("Executing checkLicenses...", Mode.Console, false);
licenseRequest = new LicenseRequest()
{
token = this.GetToken(),
licensesList = Data.GetLicensesToValidate()
};
string json = JsonConvert.SerializeObject(licenseRequest, Formatting.Indented);
var jsonBytes = Encoding.Default.GetBytes(json);
string URI = AplicationConf.GetWebServiceAddress() + "/checklicense";
var uri = new Uri(URI);
var servicePoint = ServicePointManager.FindServicePoint(uri);
servicePoint.Expect100Continue = false;
System.Net.ServicePointManager.Expect100Continue = false;
string response = "";
using (WebDownload wc = new WebDownload())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.Credentials = CredentialCache.DefaultCredentials;
wc.Proxy = GetProxyData();
wc.Timeout = 60000;
Monitor.Record("Post in URI: " + URI, Mode.Console, false);
var postResponse = wc.UploadData(URI, "POST", jsonBytes);
response = Encoding.Default.GetString(postResponse);
}
if (!String.IsNullOrEmpty(response))
{
List<ResponseLicense> responseLicense = JsonConvert.DeserializeObject<List<ResponseLicense>>(response);
Data.UpdateLicense(responseLicense);
}
Monitor.Record("CheckLicense finish");
}
nextCheck = DateTime.Now.AddHours(24);
}
}
更新
此应用程序是一个 WCF 服务,其中包含一个名为 HostServer 的类。此类有一个 Start () 方法,该方法仅在服务启动时调用一次。此方法“Start”创建 trheads。 (checkLicenses()方法是一个trhead)。下面是 Start() 代码的一部分。
public void Start (bool consoleRunning = false)
{
// code above
trheadCheckLicense = new Thread (new ThreadStart (checkLicense));
trheadCheckLicense.Priority = ThreadPriority.Normal;
trheadCheckLicense.Name = "trheadCheckLicense";
trheadCheckLicense.Start();
// More code below
}
最佳答案
您的 CheckLicense 代码未捕获任何异常。如果服务配置为在失败时重新启动。并且您的 autoResetEvent 创建类似于 new AutoResetEvent(true);你会得到一个循环:
1 service starting
2 go to check license
3 send request
4 get exception somewhere
5 crash
6 restart again
关于c# - 在我的服务器上发布帖子的 C# 线程 - Flood,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27982962/
我正在编写一种填充方法,用红色填充图像(狗的轮廓)。 在我的 TestShellDlg.cpp 中是洪水填充方法。 CTestShellDlg::m_pScreenDib 成员是一个 CDIB32 位
如果我尝试填充一个 100x100 的矩形,则会出现溢出。50x50 效果很好。 有没有办法解决溢出问题? 我还打印出 Stack Number,有时工作矩形 Stack 比大的 Stack 高(它在
游戏链接在这里: http://floodit.appspot.com/ 规则很简单,你必须从邻居中选择一种颜色,起点是左上角,然后颜色发生变化,你就淹没了更多的区域。目标是淹没整个网格。 stack
我正在使用 Java 开发一个小型绘图应用程序。我正在尝试通过实现 Flood Fill 算法来创建“桶填充”工具。 我尝试使用递归实现,但这是有问题的。不管怎样,我在网上搜索了一下,似乎为此目的,建
题目地址:https://leetcode.com/problems/flood-fill/description/ 题目描述 Animage is represented by a 2-D ar
def getRegionSize(cell, world): region = [] frontier = [cell] val = world[cell[0]][cell[
我必须找出阻碍交通的下雨阈值。 所以,我必须打印降水阈值来阻止交通。 例如) 3 3 0 1 2 1 2 3 0 2 6 输出:3 这个问题有什么好的算法或者关键词吗? 谢谢 最佳答案 找到一棵具有最
我有 N × M 个网格,其中每个单元格都用一种颜色着色。 当玩家点击颜色为 α 的网格中的任何单元格时,网格最左上角的颜色为 β 的单元格会接收到颜色 α,但不仅如此:所有连接到的单元格仅使用颜色
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 2 年前。 Improve this qu
我正在开发一个 Paint 应用程序,其中我正在实现类似于 MS Paint 应用程序的 BucketFill 功能。 我已经使用几种 FloodFill 算法对其进行了编码,但是填充颜色过程花费了太
我有一个 C# 应用程序,旨在使用线程在我的服务器中发出 http post 请求。 (这是为了简化问题,因为事实上,有几个不同的trheads在不同的URI上发出请求) 事实证明,这些踏板被设置为在
我正在尝试使用洪水填充来清理扫雷游戏中的开放区域。我做了一个简单的洪水填充函数,但我不断收到堆栈溢出错误代码 public void revealEmpty(int givenIndex){
我有一个具有以下结构的 MySQL 表: CREATE TABLE IF NOT EXISTS `np_voxels` ( `world` VARCHAR(16) NOT NULL, `x`
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 5 年前。 编辑问题以包含 desired behavior, a specific proble
我正在为 python 扫雷器实现一个 flood-fill 算法。 在我展示算法之前,让我定义一些重要的东西: BOARD,打印漂亮时,看起来像这样: X 1 1 1 3 X 2 1 2 X 2
我正在尝试使用 flood fill算法在列表中找到所有相似的相邻对象,并将它们标记为删除。我试图改编维基百科上的伪代码,但卡住了。 列表中的每个对象都有一个 int X 值、一个 int Y 值、一
我正在使用 Java 编写一个简单的绘图应用程序。我正在尝试使用 Flood Fill 算法的递归实现作为我的“桶填充”工具。 但是,这总是给我一个StackOverFlowError。 (无论我使用
我正在尝试制作 Flood-It 风格的游戏,但我遇到了主要算法的问题。 该算法会检查您已经控制的每个方 block ,并找到具有您无法控制的所选颜色的相邻方 block 。 变量: 1 - $boa
我正在寻找最有效的解决方案,有很多方法可以从套接字读取数据和解码 json。我显然应该使用 json.Encoder 和 json.Decoder,因为它们适合套接字的流式处理,但我有防止套接字泛滥的
我正在编写一种填充方法,用红色填充图像(狗的轮廓)。 在我的 TestShellDlg.cpp 中是洪水填充方法。 CTestShellDlg::m_pScreenDib 成员是一个 CDIB32 位
我是一名优秀的程序员,十分优秀!