0
votes

I got the below error when trying to connect to WCF service running on my localhost using the WCF Test Client tool. I entered the end-point address as "net.tcp://localhost:19998/MyWCFService". MyWCFService is launched within Visual Studio 2017 on my local PC.

"There was no endpoint listening at net.tcp://localhost:19998/MyWCFService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."

I can verify the port 19998 is listening on my PC using the netstat.

TCP 0.0.0.0:19998 LISTENING

I have disabled all the firewall on my PC.

2

2 Answers

1
votes

It turns out that my WCF service has some runtime errors that prohibits any clients to connect to it.. I have fixed the errors and i can connect now. Thanks.

0
votes

It seems that the error is caused by that the service address is wrong. How do you host the service on the server side? I would like you could post more details about the server side so that give you an effective reply.
Here is my example about using NetTCPBinding, wish it is useful to you.
Server

class Program
    {

        static void Main(string[] args)
        {

            Uri uri = new Uri("net.tcp://localhost:1500");
            NetTcpBinding binding = new NetTcpBinding();
            binding.Security.Mode = SecurityMode.None;
            using (ServiceHost sh = new ServiceHost(typeof(Calculator), uri))
            {
            sh.AddServiceEndpoint(typeof(ICalculator), binding,"");
            ServiceMetadataBehavior smb;
            smb = sh.Description.Behaviors.Find<ServiceMetadataBehavior>();
            if (smb == null)
            {
                smb = new ServiceMetadataBehavior();
                //smb.HttpGetEnabled = true;
                sh.Description.Behaviors.Add(smb);
            }
            Binding mexbinding = MetadataExchangeBindings.CreateMexTcpBinding();
            sh.AddServiceEndpoint(typeof(IMetadataExchange), mexbinding, "MEX");
            sh.Open();
            Console.Write("Service is ready....");
            Console.ReadLine();
            sh.Close();
            }
        }
    }
    [ServiceContract]
    public interface ICalculator
    {
        [OperationContract]
        int Test(int a);

    }
    public class Calculator : ICalculator
    {
        public int Test(int a)
        {
            return a * 2;
        }
    }

Result.
enter image description here

Feel free to let me know if there is anything I can help with.