Published on:Sep 19, 2010
Views: 7675
Number of votes: 0
Average rating:

EventReplication service with TCP

When dealing with multiple servers in load balancing scenario, you have to use EventReplication service in EPiServer in order to synchronize them. By default EPiServer comes with UDP synchronization but this won't work if multicast UDP is disabled by network administrators. The second options is to use TCP. If the version of EPiServer allows it you can enable port sharing:

   1: <bindings>
   2:     <nettcpbinding>
   3:         <binding name="PortBinding" portSharingEnabled="true" />
   4:     </nettcpbinding>
   5: </bindings> 
Here you can check more about specific implementation details:

However when using specific ports for different endpoints, only one port per endpoint is allowed. If you set to endpoints to use the same port - the following exception will be thrown:
"System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted"
This exception can occur even when using different ports. Consider the following example:
I've created a page which has method that freezes the current thread for fifty seconds: Thread.Sleep(50000)
After the thread has been put to sleep, I've recycled the application pool manually. The next request which I've made to a different page in the same website returned the exception, which I've mentioned before. Why is this happening? There is feature in IIS 6 and IIS 7 called "overlapped recycling". When activated if application pool is recycled, the next request will create a new worker process (w3wp) even if the old one is not terminated yet. This way the two processes will try to use the same port.
By default the application pools is recycled every 1740 minutes. This means that if your website is performing long running operation after recycle the exception can be thrown. To disable overlapped recycling in IIS6 you have to set DisallowOverlappingRotation metabase property to true In IIS7 select the application pool -> Advanced Settings -> Recycling section and set Disable Overlapped Recycling it to true. Also I recommend to set a specific time for recycling the website when it is less visited. This is because the worker process, which handles the request after recycle will wait for terminating the first one and is better to set it to a time when the website visit rate is lower. 

Sep 19, 2010

( 9/21/2010 10:33:37 AM)


Very interesting to know that this can happen. I think it applies both to the scenario when you use specific ports and port sharing since port sharing also requires a unique name of the end point (path changes instead of port number). Can you confirm?


( 9/21/2010 10:33:37 AM)

Yes, you are right. Unique name of the end point is required per website. I've tried using the same end point in two websites and it failed with the following exception: "The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: the URI is already registered with the service"

Pankaj Prasad
( By Pankaj Prasad, 3/2/2011 10:48:14 AM)


I had same issue in one of the load balance site and the post was of great help.

( 3/14/2012 8:35:06 PM)

Me too Pankaj - nice to see you on here btw :)

Please login to comment.