HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Configure events over WCF

Describes 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.

Configure the event system

The Optimizely Content Management System (CMS) 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 Optimizely server can be both subscriber and publisher.

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

  1. In the 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 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>
    

Use 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.

Code example for CMS 11.1 and higher:

<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
          <extensions>
            <bindingElementExtensions>
              <add name="udpTransportCustom" 
                   type="Microsoft.ServiceModel.Samples.UdpTransportElement, EPiServer.Framework.AspNet"/>
            </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>

<button class="button-toggle c-info-block__expand-button" onclick="ShowHideTextSection(this,'randomid_9cd231b1-9300-6037-711f-f202d0272f39')" data-dom-toggle="collapse">Code example for CMS 10.x</button>

<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>

Code example for CMS version 10.

<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>

Use 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>

Use 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>

Use 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>
    
        <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>