WCF Service Error Hosting – Adding reference to netTcp binding service error


 

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
   at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)

image

Metadata contains a reference that cannot be resolved: ‘net.tcp://localhost:8732/Callback.ServiceLibrary/CallbackService/’.
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was ’00:05:00′.
An existing connection was forcibly closed by the remote host
If the service is defined in the current solution, try building the solution and adding the service reference again.

Resolution:

step 1: Adding the mex metadata to the config solved the issue

Add the below endpoint to the service node

<endpoint address="mex"
                 binding="mexTcpBinding"
                 contract="IMetadataExchange"/>

step 2: Add the Service metadata tag to the service behaviors node

<serviceBehaviors>
        <behavior name="Callback.ServiceLibrary.CallbackServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="False" />
          <serviceMetadata policyVersion="Policy15"/>
        </behavior>
      </serviceBehaviors>

step 3: Use the url net.Tcp://localhost:8732/mex to add the service reference not the full url

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s