Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate socket connection reset/timeout on Windows 7

I would like to simulate a socket connection going bad in order to test my application. The goal is to verify whether my Java code behaves the way it expected to, when a long standing socket connection to a remote server gets reset at runtime or server becomes unavailable.

I tried creating a firewall rule in Windows Firewall. However, enabling the rule does not seem to affect a socket connection that is already open. Pulling the network cable is not an option because I have to perform these tests over a remote desktop connection to the server that is running my code.

like image 573
akirekadu Avatar asked Nov 14 '22 06:11

akirekadu


1 Answers

I realize that this isn't directly under Windows, but considering the nature of Java, it may still work.

There is a program called Netem under Linux, which considering your code is java, may run. I've never used it, so I can't attest to its abilities or use, but there are some examples for use here. You can fairly trivially run Linux inside a VM (like the free (as in beer, or as in the kind of free speech you enjoy in Britain) VirtualBox) and hopefully your Java app inside that.

May not be perfect, and sorry about a general lack of know-how, but it might work for what you need

like image 177
lochok Avatar answered Dec 29 '22 19:12

lochok