Month: March 2017

Faking a connection refusal


Your application connects to another server to request a service.  Most of the time this hums along with no problem.  But once in a while the server you are attempting to connect to refuses the connection.  When this happens, the phones ring off the hook.

You would like to catch this scenario before all your users get angry.  So you put some monitoring in place.

To test the monitoring, you need to fake the connection refusal.  This took me longer than I care to admit to figure out, but it turns out the answer is pretty simple.

Change the port number.

So say you have Axis2 software running at the port number you are connecting to.  Keep your connection string as it is, except for the port number.  Change the port to a number that is not running any web service software.

That will result in a Connection refused error.