Solved

WCF named pipe operation timeout

Posted on 2012-03-16
2
1,335 Views
Last Modified: 2012-03-19
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");

        }
0
Comment
Question by:Alw1n
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37730717
try to implement client in a separate application.

have a look here:-
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
0
 

Author Closing Comment

by:Alw1n
ID: 37736532
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?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now