.net 4.0 - Bad request 400 error while acessing wcf rest service frequently -


i facing problem of bad request 400 while accessing wcf service. have tried solution related topic still not solved. wcf service on iis7 .

i trying call service below code.

try         {             webclient client = new webclient();             byte[] data = client.downloaddata(applicationruntimesettings.serviceurl() + userid);             stream stream = new memorystream(data);              datacontractjsonserializer obj = new datacontractjsonserializer(typeof(string));             result = obj.readobject(stream).tostring();         }         catch (exception)         {          }           return result; 

the config file @ service below, config file same wcf web application. wcf service developed in web application , web app hosted on iis7 , accessing service in it.

the configuration file below. of time not return error breaking after time. request on wcf service frequent . data form of json.


now after making below suggested changes servicethrottling web.config file mentioned below still gives same error times.

 <system.web> <sessionstate timeout="1440"/> <customerrors mode="off"/> <httpruntime executiontimeout="90" maxrequestlength="104857600" usefullyqualifiedredirecturl="false" minfreethreads="8" minlocalrequestfreethreads="4" apprequestqueuelimit="100" enableversionheader="true"/> <!--set compilation defug="false" when releasing--> <compilation targetframework="4.0" >   <assemblies>     <add assembly="system.web.abstractions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/>     <add assembly="system.web.helpers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/>     <add assembly="system.web.routing, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/>     <add assembly="system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/>     <add assembly="system.web.webpages, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/>   </assemblies> </compilation> <authentication mode="forms">   <forms loginurl="~/account/logon" timeout="86400"/> </authentication> <pages>   <namespaces>     <add namespace="system.web.helpers"/>     <add namespace="system.web.mvc"/>     <add namespace="system.web.mvc.ajax"/>     <add namespace="system.web.mvc.html"/>     <add namespace="system.web.routing"/>     <add namespace="system.web.webpages"/>   </namespaces> </pages> </system.web> <system.webserver> <security>   <requestfiltering>     <!-- maxallowedcontentlength = bytes -->     <requestlimits maxallowedcontentlength="104857600"/>   </requestfiltering> </security> <validation validateintegratedmodeconfiguration="false"/> <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">   <dependentassembly>     <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35"/>     <bindingredirect oldversion="1.0.0.0-2.0.0.0" newversion="3.0.0.0"/>   </dependentassembly> </assemblybinding> </runtime> <system.servicemodel>  <services>   <service name="glance.dynamicbusinessservice.dynamicbusinessservice" behaviorconfiguration="servicebehaviour">     <!-- service endpoints -->     <!-- unless qualified, address relative base address supplied above -->     <endpoint address="custombinding" binding="custombinding" bindingconfiguration="basicconfig" contract="glance.dynamicbusinessservice.idynamicbusinessservice"/>     <endpoint address="" binding="webhttpbinding" contract="glance.dynamicbusinessservice.idynamicbusinessservice" behaviorconfiguration="rest">       <!--           upon deployment, following identity element should removed or replaced reflect           identity under deployed service runs.  if removed, wcf infer appropriate identity           automatically.       -->     </endpoint>   </service> </services> <behaviors>   <servicebehaviors>     <behavior name="throttlethis">       <!-- avoid disclosing metadata information, set value below false , remove metadata endpoint above before deployment -->       <servicemetadata httpgetenabled="true" />       <servicethrottling           maxconcurrentcalls="40"           maxconcurrentinstances="20"           maxconcurrentsessions="20"/>        <!-- receive exception details in faults debugging purposes, set value below true.  set false before deployment avoid disclosing exception information -->       <servicedebug includeexceptiondetailinfaults="true"/>     </behavior>   </servicebehaviors>   <endpointbehaviors>     <behavior name="rest">       <webhttp/>     </behavior>   </endpointbehaviors> </behaviors> <bindings>    <webhttpbinding>     <binding maxreceivedmessagesize="999999999" receivetimeout="24" closetimeout="24" maxbufferpoolsize="999999999" maxbuffersize="999999999">       <readerquotas maxdepth="32" maxstringcontentlength="999999999" maxarraylength="99999" maxbytesperread="4096" maxnametablecharcount="99999" />     </binding>   </webhttpbinding>    <custombinding>     <binding name="basicconfig">       <binarymessageencoding/>       <httptransport transfermode="streamed" maxreceivedmessagesize="67108864"/>     </binding>   </custombinding> </bindings> <servicehostingenvironment multiplesitebindingsenabled="true" minfreememorypercentagetoactivateservice="0"/> </system.servicemodel> </configuration> 

thanks suggestion , help.

i'd tempted comment out configuration line on client , host, , trying running it. config seems set minimums , performance limits. if doesn't change anything, might try setting performance throttling.

you add configuration , tinker settings until performance of web service smooths out. default, instance, concurrent calls 16, if raise number using servicethrottling, might better results.

<servicebehaviors>         <behavior name="throttlethis">             <servicemetadata httpgetenabled="true" />             <servicethrottling                 maxconcurrentcalls="40"                 maxconcurrentinstances="20"                 maxconcurrentsessions="20"/>         </behavior>     </servicebehaviors> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -