SPS: Socket exception error when starting service


Getting a socket exception error when starting SPS process.



The process 'SampleProcess' generated an exception.

[WebException] Unable to connect to the remote server

[SocketException] Only one usage of each socket address (protocol/network address/port) is normally permitted


   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)

   at System.Net.HttpWebRequest.GetRequestStream()

   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

   at Microdea.WebServices.DeploymentWebService.DeploymentMgmt.GetPrimarySynWebLoggingService(String& PrimaryServiceID, String& ServiceURL, String& ErrorMsg)

   at Microdea.Synergize.DeploymentManagement.GetLoggingWebService()

   at Microdea.Synergize.DeploymentManagement.get_LoggingWebServiceUrl()

   at Microdea.ProcessServer.Common.ActionLogging.LogMessage(Activity action, String applicationName, String message, LoggingMessageType logType, String metricName, Double metricValue)

   at Microdea.ProcessServer.Common.ActionLogging.LogMessage(Activity action, String message, LoggingMessageType logType)

   at Microdea.ProcessServer.Common.ActionLogging.LogError(Activity action, String format, Object[] args)

   at Microdea.ProcessServer.Core.BusinessProcess.HandleFault(ActivityExecutionContext executionContext, Exception exception)

   at System.Workflow.ComponentModel.ActivityExecutor`1.HandleFault(T activity, ActivityExecutionContext executionContext, Exception exception)

   at System.Workflow.ComponentModel.ActivityExecutor`1.HandleFault(Activity activity, ActivityExecutionContext executionContext, Exception exception)

   at System.Workflow.ComponentModel.ActivityExecutionFilter.HandleFault(Activity activity, ActivityExecutionContext executionContext, Exception exception)

   at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.HandleFault(Activity activity, ActivityExecutionContext executionContext, Exception exception)

   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)

   at System.Workflow.Runtime.Scheduler.Run()



When the process and applications make authenticated calls, the client is closing connections. And when these applications are making authenticated calls repeatedly to the same server, they are making and closing connections repeatedly. The same might happen when making regular http [un authenticated] calls but setting keep-alive = false.

When a connection is closed, on the side that is closing the connection the 5 tuple
{ Protocol, Local IP, Local Port, Remote IP, Remote Port} goes into a TIME_WAIT state for 240 seconds by default.
In this case, the protocol is fixed - TCP
the local IP, remote IP and remote PORT are also typically fixed. So the variable is the local port.
What happens is that when you don't bind a port in the range 1024-5000 is used.
So roughly you have 4000 ports. If you use all of them in 4 minutes - meaning roughly you
make 16 web service calls per second for 4 minutes you will exhaust all the ports. That is the cause of this exception.

This exception typically happens on a server that hosts multiple Synergize applications [SPS, BulkPrint, EMC] and has been observed to happen on Windows 2003/R2 servers.



1. One of the ways is to increase the dynamic port range. The max by default is 5000. You can set this up to 65534.

Open RegEdit as Admin and go to:



If MaxUserPort does not exist, create it using the following values:

                DataType - REG_DWORD

                Value - ea60 [hex value for 60000]


2. The second thing you can do is once the connection does get into an TIME_WAIT state you can reduce the time it is
in that state, Default is 4 monutes, but you can set this to 30 seconds
HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\TCPTimedWaitDelay is the key to use.
Set this to 30 seconds








Have more questions? Submit a request
Powered by Zendesk