4

I have a ASP.Net web service. There are about 150 client app continuously hit the web service say every 1 minute.

In this kind of scenario some are getting the service and some are continuously getting timed out exception. this is a data transfer service between client and service.

The request channel timed out while waiting for a reply after 00:09:59.9531343. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

I have increased the time in client side with no luck.

The Web.Config of the web service is

<?xml version="1.0"?>

<configuration>


    <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
          <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
            <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          </sectionGroup>
        </sectionGroup>
      </sectionGroup>

      <!-- For Logging Servic-->
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>

    </configSections>


  <!-- #User Settings -->
  <appSettings>


    <add key="SqlServerDBConnectionString" value="Data Source=MyServerName;Initial Catalog=dbName;User ID=myUserId;Password=myPassword;"/>

    <add key="ActiveDBConnectionString" value="SqlServerDBConnectionString"/>


    <!--<add key="DetailedLog" value="Yes"/>-->
    <add key="DetailedLog" value="No"/>

  </appSettings>
  <!--#User end-->

    <connectionStrings/>

    <system.web>
        <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
        <compilation debug="true">

          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
          </assemblies>

        </compilation>
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <!--<authentication mode="Windows" />-->
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
      <customErrors mode="Off" />
      <pages>
        <controls>
          <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </controls>
      </pages>

      <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      </httpHandlers>
      <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </httpModules>
      <httpRuntime maxRequestLength="2097151" />

    </system.web>

    <system.codedom>
      <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                  type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <providerOption name="CompilerVersion" value="v3.5"/>
          <providerOption name="WarnAsError" value="false"/>
        </compiler>
      </compilers>
    </system.codedom>

    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules>
        <remove name="ScriptModule" />
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </modules>
      <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <remove name="ScriptHandlerFactory" />
        <remove name="ScriptHandlerFactoryAppServices" />
        <remove name="ScriptResource" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </handlers>
    </system.webServer>

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

  <!-- Logging Section Start-->
  <log4net>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="DataSyncLog" />
    </root>

    <logger >
      <level value="ALL" />
    </logger>

    <appender name="DataSyncLog" type="log4net.Appender.RollingFileAppender" >
      <param name="File" value="Log.log" />
      <param name="AppendToFile" value="true" />

      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%-5p%d{ yyyy-MM-dd hh:mm:ss} – %m%n" />
      </layout>
      <lockingModel type="log4net.Appender.FileAppender+MutexLock" />
    </appender>




  </log4net>
  <!-- Logging Section End-->

</configuration>

Could someone give me some instruction that how to overcome such kind of situation?

Rezoan
  • 1,745
  • 22
  • 51

1 Answers1

0

Getting Timed Out from ASP.Net Webservice

You get this error because the data that has been passed over the wire is more than what it can handle in the specified time.

An obvious solution is to increase the timeout. But not recommended as a direct solution.

Firstly, You need to check how much data are you trying to pass? does your client really needs all that data? Secondly, Will your client wait 10 minutes for your call back?

In most of the cases answer will be NO, so you should consider using paging and sending data in chunks. If this is not suitable trim your data to the immediate needs of the user.

You might use some sort of zipping before sending and unzipping it on receiving (if you are the user of your application)

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • Thanks Ehsan. Yes compression and decompression are exist in the system. and there is not more then 1.5 mb data is transferred between client and service but not every time. this amount of data is transferred sometimes. But think if 50 client among the 150 is try to transfer this amount of data at a time what will happen? maximum time there is 50-100 kB data is transferred. Client will get exact data which it needs from service. – Rezoan Aug 13 '13 at 06:57
  • in case of 50-100kb there shouldn't be any issue at all. Even for 1.5Mb data will transfer without a problem. it means bottle neck is somewhere else in your code. might be network latency. And each client will get its own connection so it will not affect the other client. – Ehsan Aug 13 '13 at 06:59
  • the system works perfectly when there are 15-20 client but for 100 or 150, some client i saw honestly 2 or 3 client always getting the timed out exception from the service. i have understand they are not getting the service but unable to find what to do. I have simulated the service with less amount of client (10) each are transferring 10MB data each time forcefully (not necessary). and system response is fine. – Rezoan Aug 13 '13 at 07:02
  • it could be the maximum bandwidth that your server is allowing at a time – Ehsan Aug 13 '13 at 07:22
  • Ya you are right. this problem can happen when limiting the bandwidth. Honestly i have tested this yesterday. But where the web service is hosted, i see from IIS: Maximum bandwidth(bytes/sec): 4294967295 and Maximum Concurrent Connection: 4294967295 – Rezoan Aug 13 '13 at 07:28
  • This is what IIS is allowing not what your server is allowing. Check that with your hosting provider – Ehsan Aug 13 '13 at 07:30