title: WCF- System.ServiceModel.Channels.ServiceChannel has been Aborted
body: <p>Following is the Duplex Service and its WebConfig file. In the service, the transmitting client sends it data via <strong>TransmitUserData</strong> method and the receiving client receives the data via <strong>PublishUserData</strong> from CallBackContract.</p>
  
  <p>Now the issue is, if I run the clients for first time it works perfectly, but if I re-run the clients it give the following error at while <strong>Transmitting</strong>.</p>
  
  <blockquote>
    <p>The communication object, System.ServiceModel.Channels.ServiceChannel,
    cannot be used for communication because it has been Aborted.</p>
  </blockquote>
  
  <p><strong>Duplex Service Contract</strong> </p>
  
  <pre><code> [ServiceContract(CallbackContract=typeof(IContactManagerCallBackService))]
      public interface IContactManagerUserService
      {
          [OperationContract(IsOneWay = true)]
          void SubscribeAsReceiver();
  
          [OperationContract(IsOneWay = true)]
          void SubscribeAsTransmitter();
  
          [OperationContract]
          void TransmitUserData(UserInfo info);
  
      }
  
      [ServiceContract]
      public interface IContactManagerCallBackService
      {
          [OperationContract(IsOneWay = true)]
          void PublishUserData(UserInfo info);        
      }
  
      [DataContract]
      public class UserInfo
      {
          [DataMember]
          public bool PaidUser { get; set; }
  
          [DataMember]
          public string ProfileName{ get; set;}
  
          [DataMember]
          public string ComputerName { get; set; }
  
          [DataMember]
          public string IPAddress { get; set; }
  
          [DataMember]
          public string MACAddress { get; set; }
      }
  </code></pre>
  
  <p><strong>Service Implementation</strong> </p>
  
  <pre><code>   [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
      public class ContactManagerUserService : IContactManagerUserService
      {
          SynchronizedCollection&lt;IContactManagerCallBackService&gt; receiverClients;
  
          public ContactManagerUserService()
          {
              receiverClients = new SynchronizedCollection&lt;IContactManagerCallBackService&gt;();
          }   
  
          public void SubscribeAsReceiver()
          {
              IContactManagerCallBackService client = OperationContext.Current.GetCallbackChannel&lt;IContactManagerCallBackService&gt;();
              receiverClients.Add(client);
          }   
  
          public void TransmitUserData(UserInfo info)
          {
              foreach (IContactManagerCallBackService receiverClient in receiverClients)
              {
                  receiverClient.PublishUserData(info);                       
              }                
          }   
  </code></pre>
  
  <p><strong>Web.config</strong> </p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;diagnostics&gt;
        &lt;messageLogging logEntireMessage="true" logMalformedMessages="true"
          logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /&gt;
      &lt;/diagnostics&gt;
      &lt;bindings&gt;
        &lt;netTcpBinding&gt;
          &lt;binding name="NewBinding0" maxConnections="1000"
            portSharingEnabled="true"&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="ContactManagerService.ContactManagerUserService"&gt;
          &lt;endpoint address="mex" binding="netTcpBinding" bindingConfiguration=""
            name="dataEndPoint" contract="ContactManagerService.IContactManagerUserService" /&gt;
          &lt;endpoint binding="mexTcpBinding" bindingConfiguration="" name="mexHttp"
            contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="net.tcp://localhost/ContactManagerUserService" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name=""&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>The code runs perfectly for the first time.
  Actually the problem is created by Transmitter, which we never subscribe or unsubscribe.
  <img src="https://i.stack.imgur.com/eBGqo.jpg" alt="enter image description here"></p>