locked
WCF + NetTcp + Transactional service gives a protocol exception RRS feed

  • Question

  • Hello Everyone,

    I wrote a WCF service which uses NetTcp binding. Its transactional and uses streaming.

    [ServiceContract()]
        public interface ISend
        {
            [OperationContract()]
            [FaultContract(typeof(CustomException))]
            [TransactionFlow(TransactionFlowOption.Allowed)]
            SendResponse SendData(CustomMessage customMessage);


     [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
            public SendResponse SendData(CustomMessage customMessage)
            {}

    CustomMessage is a data contract, which has a property of type Stream . This stream can be  a file stream or  memory stream.
    Service works fine for small data volumes. But when I tried sending somewhat large volumes like 200MB files, service fails with following error.

    System.ServiceModel.ProtocolException: The transaction under which this method call was executing was asynchronously aborted.

     

    Server stack trace:

       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)

       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

     

    Any help would be greatly appriciated.

    Thanks and regards
    hantana

    Thursday, June 28, 2007 12:53 PM

Answers

All replies

  • Moving to our Transactions forum.
    Thursday, June 28, 2007 3:13 PM
  • Hello,

     

    What does the client code look like -- is there a transaction on the client side which gets flowed to the service or do you allow the service to create the transaction for you?  Also, how long does the transfer take? The default Transaction timeout is 1minute so you may be getting timed out here.

    Thursday, June 28, 2007 5:21 PM
    Moderator
  • Hello Jesse,

    Client code is:


    using (ChannelFactory<ISend> channelFactory =
                    new ChannelFactory<ISend>(CLIENT_SENDSERVICE_ENDPOINT))
                {
                    proxy = channelFactory.CreateChannel();
                    using (proxy as IDisposable)
                    {
                        sendResponse = proxy.SendData(customMessage);
                    }
                }

    I do not specify transaction explicitly, rather let service to create transaction. When transfer large data volumes it takes couple of minutes to complete the transaction. Config file looks follows.

     <netTcpBinding>
            <binding name="CustomTcpBinding" maxConnections="100" listenBacklog ="100"
              closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" openTimeout="00:10:00"
                       transferMode="Streamed" maxReceivedMessageSize="650000536" transactionProtocol =""/>
          </netTcpBinding>

    Since no transactionProtocol  is specified, I guess it uses default transaction protocol (OleTransactions).

    Thanks for your help.

    Regards
    hantana

    Friday, June 29, 2007 3:28 AM
  • Try the following on your Service class:

     

    [ServiceBehavior(TransactionTimeout = "00:10:00")]

     

    This means that all transactions created by the service will have a timeout of 10minutes.  If you need something longer than 10 minutes then you are bound by a setting in machine.config.  Typically one can increase this value during deployment/installation of your service (for example) if absolutely required -- but all System.Transactions will be affected by this new maximum.  See http://msdn2.microsoft.com/en-us/library/system.transactions.configuration.machinesettingssection.aspx (maxTimeout property)

     

    Also, see the following msdn article about why we should not use 'using' for client proxies.  It's somewhat odd but important. http://msdn2.microsoft.com/en-us/library/aa355056.aspx

     

    Friday, June 29, 2007 6:10 PM
    Moderator