Resolving socket exception: Connection refused

The problem: You might encounter the following error in the trace robotic logs for the Robotic Response Time agent:
[2010-12-21T21:17:20.506-04:00] - ERROR - myT6agent -
 PlaybackThreadPoolWorker-738 -
 MARequestManager.sendCommandToJvm(Command cmd) -
 java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:391)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:252)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:239)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385) 

The solution: The quick solution is to reboot the Windows agent often to avoid this problem.

The longer term solution is to create or update several configuration parameters on the agent to improve memory consumption, performance and throughput.

On supported Windows systems, you can use the following parameters:
MaxUserPort
This parameter increases the number of local TCP/IP ports that are available for temporary socket connections. A low value for this parameter creates a constraint that results in the socket exception seen in the robotic logs. The default value for this parameter is 5000. Set the MaxUserPort parameter to a higher value such as 65,500 to resolve the ConnectException problem.
TcpTimedWaitDelay
This parameter affects how quickly unused sockets are closed. By using a smaller value for this parameter, sockets that are in a TimedWait status are closed faster so that ports are more quickly freed up. The default value for this parameter is 240 (seconds). You might consider lowering this value to 30 or 60 seconds. You can view the TimedWait status using the following command:
netstat -an
To configure these parameters, use the following procedure:
  1. Select Start -> Run, and enter regedit to start the Windows Registry Editor.
  2. Navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters.
  3. Create a new REG_DWORD value named TcpTimedWaitDelay and set it to a value such as 30 (for 30 seconds, which is the minimum allowed value).
  4. Create a new REG_DWORD value named MaxUserPort and set it to a value such as 32768, giving TCP a larger range of port numbers to assign for temporary socket connections.
  5. Exit the Registry Editor and reboot your system for these changes to take effect.