Saturday 10 October 2009

Friday 9 October 2009

Simple TCP proxy for emulating the disconnection failure

Assume you have an application that connects to some resource via TCP/IP. And you need to test the case when this resource becomes suddenly unavailable - to make sure you application handles it correctly.
The simplest way to do this is to connect to the resource via a proxy:
App -> TCP proxy -> resource
then to shutdown the proxy at a given time.

The simplest TCP proxy for that will be an ssh client configured for port forwarding.
Example:
$ ssh -L localport:resource_ip:resource_port localhost

This will tell ssh to listen for incoming connections on the localport and forward all packets to resource_ip:resource_port.
So you connect your app to localhost:localport, then kill ssh and you emulated the disconnection failure.

The only requirement is you need to have ssh server running on _your_ host.

Thursday 8 October 2009