none
IPC over WCF RRS feed

  • Question

  • I have following situation: One process (for GUI) that acts like client and other processes-servers that provide information to GUI. I use WCF for communication, with following configuration:

    Server Interface:

    [ServiceContract(
        SessionMode = SessionMode.Required,
        CallbackContract = typeof(ICallback))]
    
    public interface IServerClass
    {
        ICallback getCallbackInterface();
    
        [OperationContract]
        [FaultContract(typeof(MyException))]
        void SetParam(int param);
    }

    Callback interface:

    public interface ICallback
    {
        [OperationContract(IsOneWay = true)]
        void CallbackEventOperation(double newValue);
    }

    Server implementation:

    [ServiceBehavior(IncludeExceptionDetailInFaults = true,
                     InstanceContextMode = InstanceContextMode.PerSession,
                     ConcurrencyMode = ConcurrencyMode.Multiple, 
                     UseSynchronizationContext = false)]
    public class ServerClass : IServerClass
    {
        private ICallback _callbackInterface;
    
        public ICallback getCallbackInterface()
        {
            return _callbackInterface;
        }
    
        public void SetParam(int param)
        {
            ///do something
        }
    }

    Callback implementation:

    [CallbackBehavior(
        ConcurrencyMode = ConcurrencyMode.Multiple,
        UseSynchronizationContext = false)]
    public class Callback : ICallback
    {
        public event CallbackEvent callbackEvent;
        public void CallbackEventOperation(double newValue)
        {
            if (callbackEvent != null)
            {
                callbackEvent(newDuration);
            }
        }
    }

    Client proxy:

    public class ServerProxy : DuplexClientBase<IServerClass>, IServerClass
    {
        public ICallback callback;
        public ServerProxy(ICallback callback, Binding binding, EndpointAddress remoteAddress)
        : base(new InstanceContext(callback), binding, remoteAddress)
        {
            this.callback = callback;
        }
    
        public ICallback getCallbackInterface()
        {
             return callback;
        }
    
        public void SetParam(int param)1
        {
             base.Channel.SetParam(param);
        }
    }

    usage:

    wrapper = IPCHelper.CreateProxyObject<ServerProxy, ICallback>(uri);

    I use this binding conf:

        NetNamedPipeBinding binding = new NetNamedPipeBinding();
    
        binding.SendTimeout = TimeSpan.MaxValue;
        binding.OpenTimeout = TimeSpan.FromMinutes(1);
        binding.CloseTimeout = TimeSpan.FromMinutes(1);
        binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        binding.TransferMode = TransferMode.Buffered;

    Problem is when there are many calls via WCF, GUI becomes non responsive. After about 10 minutes everything is back to normal. Another problem is that channel gets faulted if not used for couple of minutes. Is something wrong with configuration?

    Tuesday, August 25, 2015 8:07 AM

All replies

  • Hi rose_as,

    According to this case, first I want to know your max connections number , because the

    NetNamedPipeBinding default connections is 10. I suggest you can use less process than

    10 to test it.

    For another problem, in WCF if you not used the channel of a interval of time,  the default

    channel would closed, may be you can set close time as 2 min or other integer.

    For more configuration  information, please refer to the following articles:

    1.<netNamedPipeBinding>

    I hope that will be helpful to you.

    Best Regards,

    Grady


    Wednesday, August 26, 2015 3:23 AM
    Moderator
  • Hi Grady,

    I have one client, which communicates with maximum 10 servers.  For each server, there is a proxy object on client side. I keep that proxy alive whole time. 

    What are consequences of setting close time to maxValue? Is that a correct way to keep channel open?

    Best Regards,


    Wednesday, August 26, 2015 8:19 AM
  • Hi rose_as,

    You need to set ReceiveTimeout longer if you want to keep a channel open always.

    And next may be you need set inactivityTimeout in your web.config file.

    Normally,  inactivityTimeout is less than  ReceiveTimeout.

    For more information, you can refer to the following articles:

    1.ReliableSession.InactivityTimeout Property

    2.keeping a wcf callback channel open indefinitely / reconnecting from client if it faults

    Best Regards,

    Grady

    Thursday, August 27, 2015 2:36 AM
    Moderator
  • Hi Grady,

    Thank you! That solved my problem with faulted channel. However, I'm unable to address not responding GUI problem.  What may be causing it? 

    Best Regards,

    rose_as

    Friday, August 28, 2015 6:09 PM
  • Hi rose_as,

    About this issue, when the number of connections is full, the new request will return a

    timeout error. If so, we can add serviceThrottling to web.config file. Like below:

     <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="1000" maxConcurrentInstances="50000" />

    This node should be add as a child node in behavior(<behavior>).

    For more information, please refer to the following articles which may be will helpful to you.

    1.<serviceThrottling>

    2.Using ServiceThrottlingBehavior to Control WCF Service Performance

    3.How to enable user GUI response in wcf service to trigger duplex callback to client

    I hope that will be helpful to you.

    Best Regards,

    Grady


    Monday, August 31, 2015 3:31 AM
    Moderator
  • Hi Grady,

    Unfortunately, that didn't solve my problem.

    However, I found that problem with GUI is in OnPaint method.

     I am calling a method via WCF, in OnPaint. Is there any reason for that to be wrong?

    Best Regards,

    rose

     

    Thursday, September 3, 2015 10:40 AM
  • Hi rose_as,

    According to the OnPaint  method issue. Because I not familiar with GUI, so  I suggest

    you can open a new  thread to ask the related question in WPF Forum for best response.

    Best Regards,

    Grady

    Monday, September 7, 2015 9:36 AM
    Moderator
  • Hi Grady,

    OK, thank you for everything. 

    Best Regards,

    rose_as

    Wednesday, September 9, 2015 7:28 AM
  • Hi rose_as,

    You are welcome.

    Best Regards,

    Grady

    Wednesday, September 9, 2015 7:38 AM
    Moderator