locked
Problems with Hosting WCF service on IIS (Using WAS) for netTCP bindings? RRS feed

  • Question

  • User583070816 posted

    <div class="vote"> </div> <div class="post-text" itemprop="text">

    I created a simple WCF service and hosted it in IIS by creating a new website. In Web.config file,I am providing bindings for http and net tcp. I created a console client and adding service reference. It generates two binding in client config - for http and for tcp. When I try to invoke the service using tcp, I get this error -

    An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll Additional information: There was no endpoint listening at net.tcp://computername/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

    when I run using Http endpoint , it works fine. Note - I am using Windows 10 OS, IIS 10.0 and WPAS\WAS (Windows Process Activation Service) are installed. I already enabled\checked HTTP Activation, TCP Activation in .Net framework in Windows features. And modified IIS server settings to include net tcp.

    My website Web.config file looks like

    <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NewBinding0" portSharingEnabled="true">
          <security mode="None"  />
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="My" name="WCFServiceOM.Service1"> <!--  the service name must match the configuration name for the service implementation. -->
        <endpoint address="" binding="basicHttpBinding" contract="WCFServiceOM.IService1"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <endpoint  binding="netTcpBinding" bindingConfiguration="NewBinding0" contract="WCFServiceOM.IService1" />
        <endpoint address="mexOM" binding="mexTcpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8087/Service1" />
            <add baseAddress="http://localhost:7777/Service1"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehanior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="My">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    And my client App.Config look like

    <configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" />
            </basicHttpBinding>
            <netTcpBinding>
                <binding name="NetTcpBinding_IService1">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="http://computername:7777/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
            <endpoint address="net.tcp://computername/Service.svc" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
                name="NetTcpBinding_IService1" />
        </client>
    </system.serviceModel>

    </div>
    Thursday, July 13, 2017 3:41 PM

Answers

All replies

  • User1168443798 posted

    Hi AnkitaGoel,

    Thanks for your post.

    It seems you post the same issue in MSDN forum, I would suggest check my reply in below thread.

    #Problems with Hosting WCF service on IIS (Using WAS) for netTCP bindings?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5b7d650a-8d79-4357-8c38-32337d327b58/problems-with-hosting-wcf-service-on-iis-using-was-for-nettcp-bindings?forum=wcf

    If you have any issue about this, please feel free to let me know.

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 14, 2017 5:36 AM
  • User583070816 posted

    Thank you so much Edward for your reply. The solution you mentioned in MSDN forum works fine. But why it doesnot work in my case. 

    Let me explain all the steps I did in detail.

    1. Created WCF Service Library project. (because I might want to host it in some other host than IIS in future, so to keep my options open). Deleted App.config file (as for now I will not be using it)

    2. Right Click on Solution -> Add -> New Website ->  Selected WCF Service and created a website. Deleted IService1 and Service, as those will come from WCF library. 

    3. Modified Web.Config file, which is my current config file and modified Service.svc file to refer to WCF library classes. It looks like this  

    <%@ ServiceHost Language="C#" Debug="true" Service="WCFServiceOM.Service1" %>


    4. Open IIS, added a new site and mapped it to my website location. In Advanced Settings, modified enabled protocol ->http,net.tcp and Binding -> http:*:85:,net.tcp:808:*,net.msmq:localhost,msmq.formatname:localhost,net.pipe:*

    Browsing Service.svc from IIS. It opens webpage saying you created service. 

    5. Copying the URL from webpage and adding it as a service reference in a console app. It adds a service reference , generates proxy code and modify App.config file (automatically by VS).

    6. Use the following code in Console app. 

    Service1Client om = new Service1Client("NetTcpBinding_IService1");
    string om1 = om.GetData(5);
    Console.WriteLine("Result " + om1);
    Console.ReadLine();

    7. On line 2, it gives this error.

    An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll

    Additional information: There was no endpoint listening at net.tcp://Computername/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

    For Http binding it works fine.

    8. If I change binding in client's App.Config for netTCP from address="net.tcp://computername/Service.svc" to address="net.tcp://computername:8087/Service.svc" (I mentioned 8087 in web.config path -   <add baseAddress="net.tcp://localhost:8087/Service1" />

    If I do that, error changes from the above one to 

    An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll

    Additional information: Could not connect to net.tcp://computername:8087/Service.svc. The connection attempt lasted for a time span of 00:00:04.0054055. TCP error code 10061: No connection could be made because the target machine actively refused it 10.210.17.14:8087.

    Friday, July 14, 2017 6:34 PM
  • User1168443798 posted

    Hi AnkitaGoel,

    Since my solution works, and I think it is not convenience to follow the same issue with the same reply.

    Would you mind marking my solution as answer to close this thread, and for any further discussion about your steps did not work, we could focus on the thread in MSDN forum.

    Best Regards,

    Edward

    Monday, July 17, 2017 6:46 AM
  • User583070816 posted

    I marked your reply as answer. 

    Could you please help me figuring out why my set up is not working though. Thanks so much.

    Monday, July 17, 2017 2:47 PM
  • User1168443798 posted

    Hi AnkitaGoel,

    I have followed the below thread, could you check below thread, and share us more information?

    #https://social.msdn.microsoft.com/Forums/vstudio/en-US/5b7d650a-8d79-4357-8c38-32337d327b58/problems-with-hosting-wcf-service-on-iis-using-was-for-nettcp-bindings?forum=wcf 

    Best Regards,

    Edward

    Tuesday, July 18, 2017 2:12 AM