WCF CustomBinding + Duplex+ BinaryEncoding + No Security Cannot Call back

此生再无相见时 提交于 2019-12-11 06:47:07

问题


I have a Duplex service (Singleton), which used to work with WSDualHttpBinding, and after changing it to duplex CustomBinding to support BinaryEncoding for performance reasons, it stopped working. The problem traces to GetCallBackChannel always returns with same HashCode (within that service instance) for all the client requests and the List thinks it already exists in the subscribed channels and wont add to the Subscribers list. I am using C# 3.5

Please suggest a solution..

Thanks in Advance...

public void Subscribe(string topicName)
            {
                try
                {
                    Notifier.IPublishing subscriber = OperationContext.Current.GetCallbackChannel<IPublishing>();
                    Notifications.Filter.AddSubscriber(topicName, subscriber);
                }
                catch (Exception ex)
                {
                    ErrorLog.WriteToLog("Subscribe\n" + ex.ToString());
                }
            }

static public void AddSubscriber(String topicName, IPublishing subscriberCallbackReference)
        {
            lock (typeof(Filter))
            {                
                if (SubscribersList.ContainsKey(topicName))
                {
                    if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
                    {
                        SubscribersList[topicName].Add(subscriberCallbackReference);
                    }
                }
                else
                {
                    List<IPublishing> newSubscribersList = new List<IPublishing>();
                    newSubscribersList.Add(subscriberCallbackReference);
                    SubscribersList.Add(topicName, newSubscribersList);
                }
            }
        }

回答1:


Looks like this is an Undocumented Issue with .Net 3.5. Tried the same thing in .Net 4.0 it works like a charm.

My objective was to use Binary Encoding with wsDualHTTPBinding, due to the reason that Windows Server 2008/IIS7 was not an option at that time this issue was raised.

The preferred solution to use binary encoding with duplex binding is to use nettcpbinding, and it has a dependency that that IIS7 (unless you are self hosting) is required which is only available on windows server 2008 or later.

We convinced the our infrastructure group to upgrade.. and all is good now :)



来源:https://stackoverflow.com/questions/3839311/wcf-custombinding-duplex-binaryencoding-no-security-cannot-call-back

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!