none
Local socket timeout was '00:09:59.9940000'. RRS feed

  • Question

  • Hi,

        I am getting the exception as below

    The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:09:59.9669967'.

      Let me explain my requirement first I am using WCF service(Hosted as a Windows Service) and My Service has a Call back function which should receive the images not in MB's only KB's say maximum up to 800 KB so My WCF service successfully receiving the images and sending to the Client using Callback function with nettcpbinding as a byte[] here is my Server Configuration file

    <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="StreamedNetTcpBinding"
                    closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                    transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                    maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647"
                      maxStringContentLength="2147483647"
                      maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
        <services>
          <service name="TagMRZOnetoOneSvc.MRZandPFVS">
            <endpoint address="" binding="netTcpBinding" name="StreamedNetTcpBinding" behaviorConfiguration="endpointBehavior"
              contract="TagMRZOnetoOneSvc.IMRZandPFVS"/>

            <endpoint address="mex" binding="mexTcpBinding" name="MetaDataTcpEndpoint"
              contract="IMetadataExchange" />

            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:8733/TagMRZOnetoOneSvc/Service1/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="endpointBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the value below to false before deployment -->
              <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

        My Client is WPF application which will receive the Images successfully. I added my WCF service as a Rightclick-> Add service reference->browse the nettcp url Created a proxy at the Client and automatically updating my Client Config file as below

    <system.diagnostics>
        <trace autoflush="true" />
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="sdt"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData="c:\logclient.svclog"  />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>
      <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="StreamedNetTcpBinding"
                    closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                    maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647"
                      maxStringContentLength="2147483647"
                      maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
        <client>
          <endpoint address="net.tcp://10.123.41.23:8733/TagMRZOnetoOneSvc/Service1/"
            binding="netTcpBinding" bindingConfiguration="StreamedNetTcpBinding"
            behaviorConfiguration="endpointBehavior"
            contract="svcGetMRZandPFVS.IMRZandPFVS" name="StreamedNetTcpBinding">
            <identity>
              <userPrincipalName value="kba1sgp" />
            </identity>
          </endpoint>
        </client>
        <behaviors>
          <endpointBehaviors>
            <behavior name="endpointBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
      </system.serviceModel>

        After successfully receiving the Images I have Client side business Logic to send the same image not modifying image what i have received back to the service using a WCF method call byte[]  Here are my strange questions

    1.  I can able to send the Images from the Client to the WCF Service up to 60KB but not more than that if i tried to send I am getting the above mentioned error

    The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:09:59.9669967'.

      I am strange I can receive the same image from service to Client but i am not able to send Client to Service why so??

    2. My Second Question a bit clumsy after adding the WCF service in my client configuration file updating automatically when i tried to Change my nettcpbinding transfermode to streamed i am not able to Initiate any calls to my service it's failing below error

    Contract requires Duplex, but Binding 'NetTcpBinding' doesn't support it or isn't configured properly to support it.

      Please post your reply ASAP because i am struggling with this error for the past 1 week Can any body found the solution please post it Immediately this is a show stopper for me to move a head.

    I am Requesting socket connection error is not because of any time issue if i am not wrong because i have tried to increase send and receive time out more than an  1 hour as I mentioned my image sizes are not more than 800KB not even MB's 

    Thanks 

    Raju

    Saturday, October 25, 2014 3:18 AM

All replies

  • First you may want to use the DOS command "netstat -a" to check the status of the connection to help debug the problem. Yo may be having a problem because you are trying to connect to the server when you are already connected.  Below is the way I normally write my clients so I'm not reconnecting everytime I send a message.

    I also check if you have a server.close statement.  I had a problem recently where I closed a TCP connection and then it would not reconnect to a different server.   The solution I used was to eliminate the close and to use a new when I reconnected to a different server.  You are working with only one server so this shouldn't be an issue.  But what I did discover that the close statement dispose something in the client that didn't get corrected when a connect occured.

    The default condion in the Net Library is the linger state is set off which means the client will not time out and close the connection.  This doesn't mean theat the server isn't closing the connection.  The 20 to 30 second timeout is a typical time for the a server to shutdown an idle connection.  The net library may not be handling the connection close from the server.  there isn't anything you can do to correct this problem in the client.  The only solution would be to use new everytime you send data.  This may sound contradictory to what I said previously, but it is not.   There are two seperate condtions that may be happening (see below).  I'm not sure at this time which of the two problems are actaully happening.

    1) You are trying to connect when you are already connected

    2) You are trying to send a message when the connection was closed by the server.

    Class TCP
    {
        public statuc IPEndPoint ipep;
        public static Socket server;
        public TCP()
        {
            ipep = new IPEndPoint(IPAddress.Parse("192.168.0.90"), 5000);
            server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            server.Connect(ipep);
        }
        public static TCPSend(string data)
        {
            server.Send(data);                //after this if server not responds then my client aplication crashes.
            int recv;
            byte[] datarecv = new byte[70];
            recv = server.Receive(datarecv);
            string stringData = Encoding.ASCII.GetString(datarecv, 0, datarecv.Length);
        }
    }
    

    Tuesday, October 28, 2014 7:17 AM