0

i create a small wcf apps when i am testing this apps in my machine then it is working but when i run the wcf server end on another pc at my home in same network then i am getting error A remote side security requirement was not fulfilled during authentication.Try increasing the ProtectionLevel and/or ImpersonationLevel.

both the pc at my home in same work group and they can access each other. i try to find out the answer but people say this is firewall issue. so i disable firewall at both the pc but still getting the problem. here is my sample code. please guide me how can i run this wcf apps in two pc at my home network. thanks

Service end

namespace WCFSample
{
[ServiceContract]
public interface IService1
{
    [OperationContract]
    string MyName(string name);
}
}

namespace WCFSample
{
public class Service1 : IService1
{
    public string MyName(string name)
    {
        return string.Format("My Name... {0}", name);
    }

}
}

namespace ConsoleApplication1
{
class Program
{
    static ServiceHost customerHost = null;

    static void Main(string[] args)
    {
        try
        {
            HostCustomerService();

            Console.WriteLine();
            Console.WriteLine("Press any key to stop the services.");
            Console.ReadKey();
        }

            catch (Exception ex)
        {
            Console.WriteLine(ex.Message);    
        }
        finally
        {
            customerHost.Close();
        }

    }

    private static void HostCustomerService()
    {
        customerHost = new ServiceHost(typeof
            (Service1));

        ServiceEndpoint tcpEndpoint = customerHost.AddServiceEndpoint(
            typeof(IService1), new NetTcpBinding(),
            "net.tcp://192.168.1.103:9020/Service1");

        customerHost.Open();

        Console.WriteLine("{0} {1}", tcpEndpoint.Address, tcpEndpoint.Name);
        Console.WriteLine();

    }
   }
  }

client end

namespace Client1
{
class Program
{
    static void Main(string[] args)
    {
        IService1 channel = null;

        var endPoint = new EndpointAddress(
             "net.tcp://192.168.1.103:9020/Service1");
       channel  = ChannelFactory<IService1>.CreateChannel(new NetTcpBinding(), endPoint);
       Console.WriteLine("Enter Name");
       string line = Console.ReadLine();
       Console.WriteLine(channel.MyName(line));
       Console.ReadKey();
    }

 }
 }
Thomas
  • 33,544
  • 126
  • 357
  • 626

1 Answers1

0

I think by default, NetTcpBinding requires a secure channel.

When you create your binding (on client and server), instead of:

new NetTcpBinding()

Try:

new NetTcpBinding(SecurityMode.None)

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • yes this work. the code as follows. var myBinding = new NetTcpBinding(SecurityMode.None); ServiceHost duplex = new ServiceHost(typeof(ServerWCallbackImpl)); duplex.AddServiceEndpoint(typeof(IServerWithCallback), myBinding, "net.tcp://192.168.1.2:9080/DataService"); duplex.Open(); Console.WriteLine("Host is running, press to exit."); Console.ReadLine(); duplex.Close(); – Thomas Oct 28 '12 at 18:41
  • please tell me onething that how to off the security when we use app.config at client side & web.config at server side. – Thomas Oct 28 '12 at 18:41
  • http://stackoverflow.com/questions/12097331/securitymode-none-leads-to-timeoutexception-instead-of-communicationobjectfaulte http://stackoverflow.com/questions/12412111/multiple-instances-of-a-self-hosted-wcf-service http://social.msdn.microsoft.com/forums/en-US/wcf/thread/271b1816-173c-4c76-a4c4-fd9fda4b5e91/ – Thomas Oct 28 '12 at 18:46