Protocol "net.tcp" is not supported

When I try to view my service.svc file, I keep getting this error.

  • I have enabled the tcp default website in IIS.
  • Port number 808: * already there in my IIS bindings
  • Ive installed WAS and support for non http protocols ...
  • The TcpChannellistener service and tcp port exchange services are running.

But why now I can not browse the site? He continues to show: "The net.tcp protocol is not supported."

Here is my code ...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Web.Services.Description;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.IO;

namespace WcfService7
{
    public class clsMyOwnServiceHost:ServiceHostFactory
    {

               protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
               {

                   NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.None);
                   BasicHttpBinding basicbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                   WSHttpBinding wsbinding = new WSHttpBinding(SecurityMode.None);

                   baseAddresses = new Uri[] { new Uri("http://localhost/WcfService7/Service1.svc"),new Uri("net.tcp://localhost/WcfService7/Service1.svc/tcp") };
                   ServiceHost host = new ServiceHost(t, baseAddresses);
                   baseAddresses.ToList().ForEach(uri =>
                    {


                        //ServiceMetadataBehavior metabehavior = new ServiceMetadataBehavior();

                        //metabehavior.HttpGetEnabled = true;
                      //  host.Description.Behaviors.Add(metabehavior);
                        if (uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), basicbinding, "basic");
                      if(uri.AbsoluteUri.Contains("net.tcp://"))  host.AddServiceEndpoint(typeof(IService1),tcpbinding,"tcp");
                       if(uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), wsbinding, "ws");
                       if (uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");



                    });

                   return host;
               }

    }
}

Please help me...

Many thanks

+3
source share
1 answer

You need to add port for TCP for your uri. HTTP has a default port, but TCP does not work.

UPDATE

net.tcp IIS. , , / TCP.

1001 , . , 4.0, , , 4.0 .

"http, tcp".

+2

Source: https://habr.com/ru/post/1771483/


All Articles