Bug 15356 - NetTcpBinding Callback doesn't work
Summary: NetTcpBinding Callback doesn't work
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-10-11 10:29 UTC by David Lambert
Modified: 2017-09-06 16:55 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 15356 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description David Lambert 2013-10-11 10:29:27 UTC
https://bugzilla.novell.com/show_bug.cgi?id=718745

I'm experimenting the same thing apart from the fact that only one client is connected.
This exception is logged in console (same as the other bug report) Exception DispatchOperation '*' for contract 'IService' requires Invoker...

And I get this from

 Exception: System.Xml.XmlException
 Message: Expecting SynchronizationEndedResponse tag from namespace http://cloudsolutions/wimisyncservice/sync, got GetManagedFolders and http://cloudsolutions/wimisyncservice/sync instead
 StackTrace:   at System.Xml.XmlReader.ReadStartElement (System.String localname, System.String ns) [0x0007c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.XML/System.Xml/XmlReader.cs:795 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts (System.ServiceModel.Description.MessageDescription md, System.ServiceModel.Channels.Message message) [0x0003c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:411 
  at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x0004d] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:272 
  at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:91 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x0024d] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:564 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:496 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x0001c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:477 


If I set the callback methods as IsOneWay = true I get the same as https://bugzilla.xamarin.com/show_bug.cgi?id=14279 : it doesn't work without any trace.
Comment 1 David Lambert 2013-10-14 05:54:49 UTC
You can try the following code to partially reproduce. I don't see the dispatch operation exception in console but I get the same exception on the callback call. Execute the code and then in console press and hold any key and you'll get the error at some point.

With extra luck you'll get the "Exception Object of type 'System.ServiceModel.MonoInternal.DuplexServiceRuntimeChannel' doesn't match target type 'System.ServiceModel.IClientChannel'   at System.Reflection.MonoMethod.Invoke" exception also reported there https://bugzilla.xamarin.com/show_bug.cgi?id=11631 at app start.

using System;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;

namespace Test
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
    public class MyService : IMyService
    {
        private IServiceCallback _callback;

        public void Register()
        {
            _callback = OperationContext.Current.GetCallbackChannel<IServiceCallback>();
        }

        public void DoWork(string host)
        {
            try
            {
                Console.WriteLine("Server is working!");
                _callback.OnDowork(host);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }

    [ServiceContract(CallbackContract = typeof(IServiceCallback))]
    public interface IMyService
    {
        [OperationContract]
        void Register();

        [OperationContract(IsOneWay=true)] 
        void DoWork(string host);
    }

    [ServiceContract] 
    public interface IServiceCallback
    {
        [OperationContract] 
        void OnDowork(string host);
    }

    public class ServiceCallback : IServiceCallback
    {
        public void OnDowork(string host)
        {
            Console.WriteLine(host + " got called back!");
        }
    }

    [CallbackBehavior()]
    class MainClass
    {
        const int Port = 60501;

        public static void Main(string[] args)
        {
            var host = new ServiceHost(typeof(MyService)); 
            var binding = new NetTcpBinding(); 
            binding.Security.Mode = SecurityMode.None; 
            host.AddServiceEndpoint(typeof(IMyService), binding, string.Format("net.tcp://localhost:{0}", Port)); 
            host.Open(); 
            Console.WriteLine("Service started ..."); 

            var callback = new ServiceCallback();
            var proxy = GetClientProxy(callback);
            proxy.Register();
            do
            {
                proxy.DoWork("Client");     
            } while (Console.ReadKey().Key != ConsoleKey.Q);	
            host.Close();
        }

        private static IMyService GetClientProxy(IServiceCallback callback)
        {
            var factory = new DuplexChannelFactory<IMyService>(callback, new NetTcpBinding(SecurityMode.None), string.Format("net.tcp://localhost:{0}", Port)); 
            return factory.CreateChannel(); 
        }
    }
}
Comment 2 David Lambert 2013-10-14 05:58:09 UTC
Actually in the example above, you should trigger the DispatchOperation exception and it will be logged in Console right after the Xml related exceptions.