none
Error in Net.Tcp + CallBack Contract + Streaming

    Question

  • Hi all,

    I am getting following error:
    "Contract requires Duplex, but Binding 'NetTcpBinding' doesn't support it or isn't configured properly to support it."

    when i am tring to open "ServiceHost".

    Waiting for positive reply.


    Thanx in advance.
    Pratik
    Saturday, December 09, 2006 1:26 PM

Answers

  • You cannot use TCP Streaming + Duplex contracts efficiently in V1. TCP Streaming offers up IRequestChannel, and while you can convert IRequestChannel->IDuplexSessionChannel by using OneWayBindingElement+ReliableMessaging, it will be gloriously inefficient, and will also buffer up all your data, thereby removing the advantage you are trying to gain through streaming. 

    Perhaps your scenario can be met by using two services (one on the client and one on the server), and implement your duplex-ness that way? Then you can use streaming, but you need to expose an endpoint on your client so that the server can contact you directly in its app-level "callback".

    Related topics:

    http://kennyw.com/indigo/151

    http://kennyw.com/indigo/63

    http://kennyw.com/indigo/53 

    Monday, December 11, 2006 4:15 PM

All replies

  • Can you share your config file (or details about how the NetTcpBinding is configured)?

    I presume your ServiceContract has a CallbackContract?

    Saturday, December 09, 2006 5:50 PM
  • Thank you for your kind reply.

    And yes, my ServiceContract has CallbackContract.

    I am not using config file.
    Instead of that i am doing all things through coding.
    And it is as follow:



    Service:
    ======

    using System;
    using System.ServiceModel;
    using System.IO;

    namespace prjVCServices
    {
        [ServiceContract(CallbackContract = typeof(ICliDesktop))]
        public interface IsvcDesktop
        {
            [OperationContract(IsOneWay = false)]
            void svcBuildStream();

            [OperationContract(IsOneWay = true)]
            void svcSetHost();
        }

        [ServiceContract]
        public interface ICliDesktop
        {
            [OperationContract(IsOneWay = false)]
            void cliSetStream(Stream xyz);
        }

        public static class MainInfo
        {
            public static ICliDesktop myCli;
            public static System.IO.FileStream myStr;
            public static byte[] myBytes;
        }
       
        [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
        public class svcDesktop : IsvcDesktop
        {
            public svcDesktop()
            {

            }

            public void svcBuildStream()
            {
                MainInfo.myStr = new FileStream(@"D:\WCF-Streaming\a1.JPG", FileMode.Open, FileAccess.Read);
                MainInfo.myCli.cliSetStream(MainInfo.myStr);
            }

            public void svcSetHost()
            {
                MainInfo.myCli = OperationContext.Current.GetCallbackChannel<ICliDesktop>();
            }
        }
    }




    Hosting Service:
    ===========
    public partial class Window1 : System.Windows.Window
        {
            System.ServiceModel.NetTcpBinding binding = new System.ServiceModel.NetTcpBinding();
            System.ServiceModel.ServiceHost imgTrans;
            Uri uri;

            public Window1()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(Window1_Loaded);
                binding.TransferMode = TransferMode.Streamed;
                binding.PortSharingEnabled = true;
                binding.MaxReceivedMessageSize = 360000;
            }

            void Window1_Loaded(object sender, RoutedEventArgs e)
            {
                try
                {
                    imgTrans = new System.ServiceModel.ServiceHost(typeof(prjVCServices.svcDesktop));
                    imgTrans.AddServiceEndpoint(typeof(prjVCServices.IsvcDesktop), binding, "net.tcp://" + Environment.MachineName + ":2500/ImgServer");
                    imgTrans.Open();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message.ToString());
                }
            }
        }



    By running this i am getting the error on "imgTrans.Open();" statement execution.


    Thanking You
    Pratik
    Sunday, December 10, 2006 6:14 AM
  • You cannot use TCP Streaming + Duplex contracts efficiently in V1. TCP Streaming offers up IRequestChannel, and while you can convert IRequestChannel->IDuplexSessionChannel by using OneWayBindingElement+ReliableMessaging, it will be gloriously inefficient, and will also buffer up all your data, thereby removing the advantage you are trying to gain through streaming. 

    Perhaps your scenario can be met by using two services (one on the client and one on the server), and implement your duplex-ness that way? Then you can use streaming, but you need to expose an endpoint on your client so that the server can contact you directly in its app-level "callback".

    Related topics:

    http://kennyw.com/indigo/151

    http://kennyw.com/indigo/63

    http://kennyw.com/indigo/53 

    Monday, December 11, 2006 4:15 PM
  • Hi Kenny,

     

    I have a problem in which i have to use duplex binding (am using wsdualhttpbinding) , and do file transfer both ways using multiple concurrency mode....

     

    i.e. i have lets say 5 4gb files ..... on both sides....

    that is  lets say 5 4gb files on client, 8 4gb files on server...............

     

    i need to transfer files from client to server and server to client..... am using callback interface to transfer files from server.....

     

    i cant use the above solution because..... once the client initiates any action, only then server has to initiate action that too on the same connection........

     

    am using multiple concurrency mode both on server and on client..............

     

    How can i use streaming for this...... ? because am facing memory problems........

     

    what do u think is the best way to go about this?

     

     

     

     

    Monday, October 01, 2007 1:29 PM
  • You cannot use TCP Streaming + Duplex contracts efficiently in V1. TCP Streaming offers up IRequestChannel, and while you can convert IRequestChannel->IDuplexSessionChannel by using OneWayBindingElement+ReliableMessaging, it will be gloriously inefficient, and will also buffer up all your data, thereby removing the advantage you are trying to gain through streaming. 

    Perhaps your scenario can be met by using two services (one on the client and one on the server), and implement your duplex-ness that way? Then you can use streaming, but you need to expose an endpoint on your client so that the server can contact you directly in its app-level "callback".

    Related topics:

    http://kennyw.com/indigo/151

    http://kennyw.com/indigo/63

    http://kennyw.com/indigo/53  


    sorry to bring up this thread from the past, but i'm desperately looking for a solution for this problem.
    i tried using the Chunking example from Microsoft, but this seems to be highly complex, and to be honestly, beyond my understanding.

    so what i'm trying to do is to upload huge (++1GB) files to a server (residing in the DMZ) from our production VLAN, using WCF. after the files have been uploaded, they should be AV scanned and added to a zip archive. now all of this is working fine, already, even with BasicHttpBinding.

    now what i want to do is to inform the client about the current progress, hence duplexing. every attempt so far using  NetTcpBinding AND streaming the same time failed. i can use NetTcpBinding for buffered transfers and duplexing is working fine. using buffered transfers however leads to consuming all available memory sooner or later. the very moment i configure my binding for Streamed Transfer i get the ""Contract requires Duplex, but Binding 'NetTcpBinding' doesn't support it or isn't configured properly to support it." error.

    any ideas would be greatly appreciated.

    Wednesday, August 05, 2009 1:27 PM
  • anyone?
    Tuesday, August 11, 2009 9:52 AM