Link to home
Start Free TrialLog in
Avatar of Alw1n
Alw1n

asked on

WCF named pipe operation timeout

Hi,
I am new to WCF and have created a small test app (server and client all contained in one win form). When testing the client bit seems to find the server but eventually times out, it seems that the server method is not returning in time.
Please see if you can see what I am doing wrong in the code below :

        [ServiceContract]
        public interface IReturnText
        {
            [OperationContract]
            string ReturnSomeText(string value);
        }

        public class ReturnText : IReturnText
        {
            public string ReturnSomeText(string value)
            {
                return "returned: " + value;
            }
        }


        private ServiceHost host;

        private void bStartService_Click(object sender, EventArgs e)
        {

            host = new ServiceHost(typeof(ReturnText),
                    new Uri[]{
                            new Uri("net.pipe://localhost")
                            });

            host.AddServiceEndpoint(typeof(IReturnText), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), "MyPipe");

            host.Open();
       
        }


        private void bStopService_Click(object sender, EventArgs e)
        {
            host.Close();
        }

        private void bUserService_Click(object sender, EventArgs e)
        {

            ChannelFactory<IReturnText> pipeFactory =
                new ChannelFactory<IReturnText>(
                    new NetNamedPipeBinding(NetNamedPipeSecurityMode.None),
                    new EndpointAddress("net.pipe://localhost/MyPipe"));

            IReturnText pipeProxy = pipeFactory.CreateChannel();
            ((IContextChannel)pipeProxy).OperationTimeout = new TimeSpan(0, 0, 5);
            string s = pipeProxy.ReturnSomeText("abc");

        }
ASKER CERTIFIED SOLUTION
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alw1n
Alw1n

ASKER

argh! thanks I did it in one app for easier testing, still not sure why it doesn't work when in the same app though?