Hide menu Last updated: Oct 27 2016
Area: Episerver CMS Applies to versions: 10 and higher
Other versions:

Configuring events over WCF

This topic contains functional and technical information for the Microsoft Windows Communication Foundation (WCF)-based event provider. This provider supplies a model for object-oriented interface definitions and configurable interprocess communication methods, without the need to change code. This provider is the default provider.

Configuring the event system

The Episerver event system is used for distributing events between websites in a multi-site and/or load-balanced scenario. The configuration consists of two parts: subscriber and publisher. An Episerver server can be both subscriber and publisher.

The Subscriber works as a WCF Server, therefore configure it as WCF Service. To configure the Episerver Event System Subscriber, make the following checks/adjustment to the Episerver CMS web.config file:

  1. In the <configuration> section, ensure the following system.serviceModel section exists and insert the subscriber WCF Service element. Mandatory values are shown in the example (for example, contract name and name of WCF service) and the asterisk (*) indicates the custom value. See the Microsoft documentation about WCF configuration for more information.
    <system.serviceModel>
    ...
        <services>
           <service name="EPiServer.Events.Remote.EventReplication" 
                     behaviorConfiguration="*">
               <endpoint name="RemoteEventServiceEndPoint" 
                         contract="EPiServer.Events.ServiceModel.IEventReplication"
                         binding="*" address="*" />
           </service>
        </services>
    ...
    </system.serviceModel>
  2. In the <configuration> section, ensure the following system.serviceModel section exists and insert the subscriber WCF client element. The mandatory values are shown in the example (such as, name and contract ) and the asterisk (*) indicates the customer value. See the Microsoft documentation about WCF configuration for more information.
    <system.serviceModel> 
    ... 
        <client> 
            <endpoint name="*" address="*" binding="*" bindingConfiguration="*" 
                      contract="EPiServer.Events.ServiceModel.IEventReplication" /> 
        </client> 
    </system.serviceModel>

Using UDP for remote events

An example configuration using UDP multicast. Be sure to use unique port numbers if you have multiple installations on the same network.

Note: UDP multicast is not supported in Azure Virtual Networks.

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      <extensions>
        <bindingElementExtensions>
          <add name="udpTransportCustom" type="Microsoft.ServiceModel.Samples.UdpTransportElement, EPiServer.Events"/>
        </bindingElementExtensions>
      </extensions>
      <services>
        <service name="EPiServer.Events.Remote.EventReplication" >
        <endpoint name="RemoteEventServiceEndPoint"
                contract="EPiServer.Events.ServiceModel.IEventReplication"
                binding="customBinding"
                bindingConfiguration="RemoteEventsBinding"
                address="soap.udp://239.255.255.19:5000/RemoteEventService" />
        </service>
      </services>
      <client>
        <endpoint name="RemoteEventServiceClientEndPoint"
           address="soap.udp://239.255.255.19:5000/RemoteEventService"
           binding="customBinding"
           bindingConfiguration="RemoteEventsBinding"
           contract="EPiServer.Events.ServiceModel.IEventReplication" />
      </client>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DebugServiceBehaviour">
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="RemoteEventsBinding">
          <binaryMessageEncoding />
          <udpTransportCustom multicast="true"/>
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>

Using TCP for remote events

An example configuration using TCP as the protocol. In the following example, the server with IP 192.168.1.1 is configured to communicate with servers 192.168.1.2 and 192.168.1.3. Each server should have an unique configuration to expose 1 service and have multiple clients to communicate with other servers.

Server 1 example:

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
    	<service name="EPiServer.Events.Remote.EventReplication">
	      <endpoint
	      name="RemoteEventServiceEndPoint"
	      contract="EPiServer.Events.ServiceModel.IEventReplication"
	      bindingConfiguration="RemoteEventsBinding"
	      address="net.tcp://192.168.1.1:5000/RemoteEventService"
	      binding="netTcpBinding" />
	    </service>
    </services>
    <client>
      <endpoint name="192.168.1.2"
         address="net.tcp://192.168.1.2:5000/RemoteEventService"
         binding="netTcpBinding"
         bindingConfiguration="RemoteEventsBinding"
         contract="EPiServer.Events.ServiceModel.IEventReplication" />
      <endpoint name="192.168.1.3"
         address="net.tcp://192.168.1.3:5000/RemoteEventService"
         binding="netTcpBinding"
         bindingConfiguration="RemoteEventsBinding"
         contract="EPiServer.Events.ServiceModel.IEventReplication" />
    </client>
  <behaviors>
    <serviceBehaviors>
      <behavior name="DebugServiceBehaviour">
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
        <netTcpBinding>
        <binding name="RemoteEventsBinding" portSharingEnabled="true">
          <security mode="None" />
        </binding>
      </netTcpBinding>
  </bindings>
</system.serviceModel>

Using a separate configuration file per IIS web site

You can have different configurations for different IIS sites by moving the configuration to a separate file prefixed with the name of the IIS site followed by a underscore. This type of configuration is useful in the multi-site and/or load-balanced scenario when sites share a physical path. Name the file [IIS web site name]_web.config where the name is the name of the IIS site.

<configuration>
    <system.serviceModel>
    ...
        <services>
            <service name="EPiServer.Events.Remote.EventReplication" 
                         behaviorConfiguration="*">
                  <endpoint name="RemoteEventServiceEndPoint" 
                         contract="EPiServer.Events.ServiceModel.IEventReplication"
                         binding="*" address="*" />
            </service>
        </services>
    ...
    </system.serviceModel>
</configuration>

Using a separate service name per IIS web site

You can have different configurations for different IIS sites by prefixing the name of the service with the name of the IIS site followed by a slash. This type of configuration is useful in the multi-site and/or load-balanced scenario when sites share a physical path.

<system.serviceModel>
...
    <services>
       <service name="[IIS web site name 1]/EPiServer.Events.Remote.EventReplication" 
                 behaviorConfiguration="*">
           <endpoint name="RemoteEventServiceEndPoint" 
                     contract="EPiServer.Events.ServiceModel.IEventReplication"
                     binding="*" address="*" />
       </service>
    </services>

       <service name="[IIS web site name 2]/EPiServer.Events.Remote.EventReplication" 
                 behaviorConfiguration="*">
           <endpoint name="RemoteEventServiceEndPoint" 
                     contract="EPiServer.Events.ServiceModel.IEventReplication"
                     binding="*" address="*" />
       </service>
    </services>
...
 </system.serviceModel>

Related topics

Comments

When enabling TCP events, I needed to turn on the net.tcp service on each machine, and to enable the net.tcp protocol to each iis site.