Click here to Skip to main content
14,970,304 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have developed WCF service that returns the bytes of the file.

But If the file size is more than 40 MB it is giving me the error

Exception Message: An error occurred while receiving the HTTP response to http://localhost:56198/Service.svc.This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

Inner Exception Message: The underlying connection was closed: An unexpected error occurred on a receive.

Inner Exception Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

Inner Exception Message: An existing connection was forcibly closed by the remote host

My Web.config is

XML
<bindings>
      <basicHttpBinding>
        <binding name="basicHttpEndpointBinding" closeTimeout="01:01:00"
          openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
          messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
            maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehavior1" name="Service">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpEndpointBinding" contract="IService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior1">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>



I have done the same changes on the CLient side but still no success

What I have tried:

I have tried changing the bindings properties
Posted
Comments
G3Coder 21-Oct-16 8:14am
   
Hi there,

I don't think the size of the file is the problem - in my experience the error produced when you exceed the size mentions the size as a constraint. Could you maybe provide the client config?
Pratik 10834354 23-Oct-16 6:57am
   
Yes,you are right. Problem is not with the file size because their max file size is 3 MB. They are calling my service in a loop (contains 105 files) through scheduler.
I checked that in my system but it is not giving any error,I checked with 50 files of more than 10 MB files.

My Web.config is (Client Side)

<system.servicemodel>
<bindings>
<basichttpbinding>
<binding name="BasicHttpBinding_IService">



<behaviors>
<endpointbehaviors>
<behavior name="debuggingBehaviour">
<datacontractserializer maxitemsinobjectgraph="2147483646">



<client>
<endpoint address="http://192.168.0.132:8099/Service.svc" binding="basicHttpBinding" bindingconfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService" name="BasicHttpBinding_IService">



Web service is not giving detailed error, its giving only "An error occurred while receiving the HTTP response ..." if they are trying single file and "The underlying connection was closed: An unexpected error occurred on a receive" if they are trying multiple files.

Also Note, previously they were getting many errors but after giving updated Web.config (increased size and readerQuota parameters) they are getting less errors.
Tom Wauters 23-Oct-16 4:43am
   
Hi,
Like G3Coder says, I also do not think the size of the file is the problem. When the service gets faulted, it deposes his channel with the client. The client is unaware of this and still uses this channel to communicate with the service. When this happens you could also get this error. If the service is yours, try to debug your service and check at what point you are getting the error. If the service is not yours, ask the owner of the service to set the <servicedebug includeexceptiondetailinfaults="false"> to true so you have an error message back from the service.
Pratik 10834354 23-Oct-16 7:04am
   
yes,problem is not with the size and I have already set <servicedebug includeexceptiondetailinfaults="false"> to true but still its not giving actual error.
G3Coder 24-Oct-16 4:25am
   
Hi,
Have you tried the WCF tracing? Specifically <source name="System.ServiceModel" switchvalue="Warning" />

https://msdn.microsoft.com/en-us/library/ms751526(v=vs.110).aspx

G

1 solution

HI,

I think problem is in following :

transferMode
Contract
behaviorConfiguration
behavior name=ServiceBehavior1

Look into this and try to solve.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900