如何重现静默删除的TCP / IP连接? [英] How to reproduce a silently dropped TCP/IP connection?

查看:277
本文介绍了如何重现静默删除的TCP / IP连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这样一种情况:Java程序与服务器建立了长时间运行的TCP / IP连接,并且所说的连接完全按照文档记录的那样运行,除了我控制之外的环境中的一件事。



每周六服务器重新启动,但由于某种原因,这不能正确地传达给我的客户端,因此连接只是挂起等待永远和永远的响应。这与陈旧的JDBC连接完全相同,其中服务器和客户端之间的某些路由器发现连接处于空闲状态并且在没有通知的情况下将其丢弃。



I需要能够重现此方案才能创建正确的修复程序。



因此我需要知道是否有一种很好的方法可以模拟路由器静默地丢弃我控制下的连接?



我可以在我的开发环境和服务器之间安装Linux机器或Mac。我可以在虚拟机(vmware播放器)中运行JVM,如果我可以在那里进行删除。



非常欢迎建议。






编辑2012-12 -18:对我有用的解决方案是在本地使用基于Java的SOCKS5代理,可以随意使用Ctrl-Z暂停,并告诉我的应用程序通过它。

解决方案

使用 Socat 转发您的连接(非常简单如果你愿意,甚至在同一台机器上设置为TCP转发器/代理(通过引入代理的新端口来操作并将其指向'官方'端点)



查看简单TCP转发器示例



然后,当您想要测试中断时,您可以终止它(并且套接字将被关闭)或者可能尝试停止进程(CTRL Z linux)以查看目标如何处理停滞的连接。 / p>

有任何问题吗?我会试着回答......祝你好运!


I have a situation where a Java program establishes a long-running TCP/IP connection to a server and said connection is functioning exactly as documented, except for one thing in an environment outside my control.

Every Saturday that server is rebooted, but for some reason this is not communicated properly to my client so the connection just hangs waiting for a response for ever and ever. This is exactly the same behaviour seen with stale JDBC-connections, where some router in between server and client has found the connection to be idle and dropped it without notification.

I need to be able to reproduce this scenario to be able to create a proper fix.

Hence I need to know if there is a good way to simulate a router silently dropping connections under my control?

I can put a Linux box or a Mac between my development environment and the server. I can run the JVM in a virtual machine (vmware player) if I can do the dropping there.

Suggestions are very welcome.


EDIT 2012-12-18: The solution that worked for me was to use a Java-based SOCKS5-proxy locally which could be suspended with Ctrl-Z at will, and tell my application to go through it.

解决方案

Use Socat to forward your connection (it's very easy to set up as a TCP forwarder/proxy) even on the same machine if you want (by introducing a new port for the proxy to operate on and pointing it to the 'official' endpoint)

Check out the simple TCP forwarder example

Then when you want to test outages you can either kill it (and the socket will be closed) or potentially try stopping the process (CTRL Z linux) to see how your destination handles stalled connections.

Any questions? I'll try to answer... Good luck!

这篇关于如何重现静默删除的TCP / IP连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆