Thomas
Thomas

Reputation: 34188

The protocol 'net.tcp' is not supported issue regarding WCF

first i create a WCF service application where svc file is created. then i write my small service related code. when i hit F5 then wcf test client appear fine and when i select svc file and select view in browser option then everything works fine. initially i have only one endpoint in config file...that is wsDualHttpBinding then everything working fine.

the moment i add another endpoint called netTcpBinding then problem start. after adding netTcpBinding endpoint in config file and when i try to browse svc file again in browser then i got error message called The protocol 'net.tcp' is not supported and when i hit F5 then wcf test client show error message called ** Cannot obtain Metadata from http://localhost:30996/ChatService.svc**

i just do not understand why it happens when i add netTcpBinding. onething i like to say that i have not hosted my service anywhere. i just create WCF service application and add all the entries in web.config file and just press F5. is this the reason i am getting error because i have not hosted my services anywhere?

so here is my config details as follows

<?xml version="1.0"?>
<configuration>

    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>

  <system.serviceModel>
    <services>
      <service name="BBAChatService.ChatService" behaviorConfiguration="BBAChatService.ChatServiceBehavior" >
        <host>
          <baseAddresses>
            <add baseAddress ="http://localhost:30996/ChatService.svc/"/>
            <add baseAddress ="net.tcp://localhost:30997/ChatService/"/>
          </baseAddresses>
        </host>

        <endpoint name="dual_bind"
                  address="dual"
                  binding="wsDualHttpBinding" 
                  bindingConfiguration="WSDualHttpBinding_IChatService" 
                  contract="BBAChatService.IChatService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

        <endpoint name="tcp_bind"
              address="net.tcp://localhost:30997/ChatService"
              binding="netTcpBinding"
              bindingConfiguration="tcpBinding"
              contract="BBAChatService.IChatService">
        </endpoint>

        <endpoint address="net.tcp://localhost:30997/ChatService/mex"
                          binding="mexTcpBinding"
                          contract="IMetadataExchange"/>


      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BBAChatService.ChatServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding"
                         maxBufferSize="67108864"
                         maxReceivedMessageSize="67108864"
                         maxBufferPoolSize="67108864"
                         transferMode="Buffered"
                         closeTimeout="00:00:10"
                         openTimeout="00:00:10"
                         receiveTimeout="00:20:00"
                         sendTimeout="00:01:00"
              portSharingEnabled="true"
                         maxConnections="100">
          <security mode="None">
          </security>
          <readerQuotas maxArrayLength="67108864"
                                  maxBytesPerRead="67108864"
                                  maxStringContentLength="67108864"/>
          <reliableSession enabled="true" inactivityTimeout="00:20:00"/>
        </binding>
      </netTcpBinding>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IChatService"
                 closeTimeout="00:01:00"
                 openTimeout="00:01:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:01:00"
                 bypassProxyOnLocal="false"
                 transactionFlow="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="524288"
                 maxReceivedMessageSize="65536"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" 
                        maxStringContentLength="8192" 
                        maxArrayLength="16384" 
                        maxBytesPerRead="4096" 
                        maxNameTableCharCount="16384"/>
          <reliableSession 
            ordered="true" 
            inactivityTimeout="00:10:00"/>
          <security mode="Message">
            <message clientCredentialType="Windows" 
                     negotiateServiceCredential="true" 
                     algorithmSuite="Default"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

just tell me what is missing....what i need to change in my config file.

here is the screen shot of my project solution explorer.

enter image description here

Upvotes: 0

Views: 3635

Answers (1)

dmusial
dmusial

Reputation: 1564

The built-in web server which is used by VS when you hit F5 supports only HTTP activation so you won't be able to host a net.tcp endpoint in it. You can either:

  • Host it in IIS (with Non-HTTP activation enabled)
  • Write a simple host application for your service
  • Use WcfSvcHost.exe which can be found in %VS INSTALLATION DIR%\Common7\IDE

Once you've hosted the service properly you'll have to create a metadata exchange endpoint for it (binding type is mexTcpBinding) and set httpGetEnabled to false in the behavior configuration for your net.tcp endpoint.

EDIT : For WcfSvcHost.exe detailed usage description please refer to this msdn article. As for the httpGetEnabled i meant to set it to false on the serviceMetadata in behavior of the net.tcp service endpoint.

<serviceBehaviors>
    <behavior name="BehaviorName">
      <serviceMetadata httpGetEnabled="false" />
    </behavior>
<serviceBehaviors>

Then just apply this behavior to your net.tcp endpoint. I assumed you'll want to expose the metadata over TCP (not HTTP) for this endpoint and in such case you'll need to include a mexTcpBinding endpoint.

Upvotes: 2

Related Questions