我正在构建一个 24/7 运行的客户端服务器应用程序。 这些应用程序旨在检测网络故障(使用心跳)并尽快重新连接到服务器。
我所做的第一个测试只是停止客户端或服务器,然后重新启动,一切正常。 我想知道是否有任何工具可以帮助我模拟拥塞、延迟或更现实的问题,而不仅仅是拔掉以太网电缆。
I’m building a client server application that should operate 24/7. The applications is designate to detect network failures (using a heart beating) and reconnect to the server asap.
The first test that I made is just stopping the client or the server and then starting again and everything works fine. I’m wondering if there is any tools that can help me simulate congestion, delays or more realistic problem than just unplugging my Ethernet cable.
发布评论
评论(2)
该应用程序是否使用普通 tcp 套接字? 或者它使用 HTTP/HTTPS 吗? 如果它基于 HTTP,Fiddler (以及其他一些代理服务器)具有以下功能:模拟慢速连接速度,尽管代价是仅限于 Windows。
另外,我对 Apache TCPMon 及其 ilk。 这些可以很好地模拟拥塞和断线,尽管根据我的经验,您最终仍然会在现实世界中发现新的有趣的故障模式。
Does the app use plain tcp sockets? Or does it use HTTP/HTTPS? If its HTTP based, Fiddler (as well as some other proxy servers) has the capability of simulating slow connection speeds, albeit at the expense of being windows only.
Alternatively, I've had good experiences with tools like Apache TCPMon and its ilk. These can simulate congestion and line breaks fairly well, although in my experience, you will still end up finding new and interesting failure modes in the real world.
Sniffy 允许您阻止 Java 应用程序中的传出网络连接 - 每当您尝试与受限主机建立新连接时,它都会抛出
ConnectException
。只需将
-javaagent:sniffy.jar=5559
添加到您的 JVM 参数中,并将浏览器指向localhost:5559
- 它将打开一个网页,其中包含所有已发现的与下游系统的连接以及禁用某些连接的控件。目前(从版本 3.1.3 开始)它仅支持无连接场景,但增加延迟正在计划中。
免责声明:我是 Sniffy 的作者
Sniffy allows you to block outgoing network connections in your Java applications - it will throw a
ConnectException
whenever you try to establish a new connection to restricted host.Just add
-javaagent:sniffy.jar=5559
to your JVM arguments and point your browser tolocalhost:5559
- it will open a web page with all discovered connections to downstream systems and controls to disable certain connections.Currently (as of version 3.1.3) it only supports no-connectivity scenarios, but adding latency is on the road map.
Disclaimer: I'm the author of Sniffy