endpoint not reachable when request is too large (30 Mb +) - asp.net

I'm trying to upload files via MVC and WCF.
My web.config on MVC project is configured to recive large files.
<binding name="BasicHttpBinding_IFile" closeTimeout="00:30:00"
openTimeout="00:30:00" sendTimeout="00:30:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom" />
The problem occurs when I call my WCF. The endpoint is right on MVC project and the web.config on WCF has this binding:
<basicHttpBinding>
<binding name="FileUploadServiceBinding"
transferMode="Streamed"
messageEncoding="Mtom"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
receiveTimeout="00:30:00"
openTimeout="00:30:00"
closeTimeout="00:30:00"
sendTimeout="00:30:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxDepth="100"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
I'm sending files of 25Mb and it's working, but when I try to upload files of 30Mb or more, my project can't reach the service, throwing this error message:
"There was no listening endpoint at http://localhost:55010/FileService.svc able to accept the message." This is usually caused by an incorrect SOAP address or action. Get more details. "
Thank you!

If you're hosting your service in IIS Express, or IIS, chances are the default value for the maxAllowedContentLength of the Request Filtering module is getting in the way (it's 30000000 by default).
Try increasing it by adding something like the following in your web.config file:
<system.webServer>
<security>
<requestFiltering >
<requestLimits maxAllowedContentLength="52428800" />
<requestFiltering>
</security>
</system.webServer>

I fixed the problem on server's web.config with the following line:
<httpRuntime targetFramework="4.5" enableVersionHeader="false" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
Now my problem is the System.OutOfMemoryException when i'm trying to copy my stream to a memorystream, but it's out of this post escope.
Thank you guys!

Related

how to pass large data to service layer using wcf service?

I am trying to implement attachment functionality in one of my web application. It has three layer. Presentation, Business and Service Layer and i have blob datatype in database of attachment field....i am getting below Error while transferring data from business layer to service layer.
The remote server returned an unexpected response: (400) Bad Request
I cant find any solution even i tried with increase arraylength, buffersize etc...But still getting error...So if anyone have any idea than please help me....I am facing this issue since 5 days.....
Here is my web.config settings
<binding name="BasicHttpBinding_ITestService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="83886080" maxBufferPoolSize="83886080" maxReceivedMessageSize="83886080"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
turn on WCF tracing on server side by adding following section to WCF host's configuration file. you will be able to get more specific reason for your failure from the trace file.
<system.diagnostics>
<trace autoflush="false"/>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\ServiceTrace.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
You need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations.
Detailed examples and consideration has been posted already at following links.
http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations. Detailed examples and consideration has been posted already at following links. http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html

Error 413 when uploading large files using WCF Service on IIS7`

I have a web application which enables users to upload files. The files are then saved using a WCF service on another service. This uploading works fine until I upload a file around 4.5 MB. When I upload a file above a certain size, I get the error:
Soap Error: 413 The server is refusing to process a request because the request entity is larger than the server is willing or able to process...
This error appears in the system event log of the server on which the WCF service is running.
The solutions that I've found have told me to change the maxAllowedContentLength and uploadReadAheadSize settings in the applicationHost config file. However changing the maxAllowedContentLength to only created a different error if I set it to something really small and changing the uploadReadAheadSize value didn't have any effect on the problem. Does anyone know what I have to change and where I have to change it? I've been looking for hours and I'm starting to get impatient :(. Thanks for the help!
EDIT:
Ok the web.config of the WCF Service located in the on the production system is as follows. This is the web.config located in the folder that the IIS Site of the WCF Web Services points to:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="SOAP" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files (x86)\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" preCondition="bitness32" />
<add name="WSDL Mapping" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
The configuration on the test system is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="WSDL Mapping" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
As you can see, there is no mention of any content length or anything in either one of the files. I have to admit, I'm pretty stumped at this point. But like I said, I'm no expert in things IIS.
EDIT 2:
Here is the serviceModel node of my web application's web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WsJobsSoapBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://srvts01test:90/WsJobs.WSDL" binding="basicHttpBinding" bindingConfiguration="WsJobsSoapBinding" contract="JobsWs.WsJobsSoapPort" name="WsJobsSoapPort"/>
</client>
</system.serviceModel>
This is the web.config of my web application that calls the WCF service and not the web.config of the WCF service itself. Thanks again for any help :)
I found an article that talks about the 45KB size limit you mentioned in the chat. It includes the configuration changes that were made.
http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP
It's possible that your test environment has these changes made so that's one thing to look for/consider. People sometimes don't overwrite configuration files during deployment so you may have an old file there that just works.
You want to change the MaxReceivedMessageSize.
I think when I did this I also had to change the MaxBufferPoolSize to the same value.
You can do it via the config or via code like this.
binding.MaxBufferPoolSize = 67108864;
binding.MaxReceivedMessageSize = 67108864;
I was also having these 413 errors in my WCF Service, which was running under .Net 4.5.
The solution was simple.
Previously, my web.config contained this:
<services>
<service name="PocketCRMServices.Service1">
<endpoint address="../Service1.svc"
binding="webHttpBinding"
contract="PocketCRMServices.IService1"
behaviorConfiguration="webBehaviour" />
</service>
</services>
So, by default, it was already using the webHttpBinding binding.
To get rid of the 413 errors, I just needed to add this straight after this section:
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647777" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
And that's it.

Publishing A WCF Service

I am deploying a web application to a remote server. I set up IIS 7 and the site comes up.
As part of the web application there is a service reference to a wcf service.
All of this works fine on my localhost everything runs.
I never did anything with the service itself on the deployment server. I just set up the web application in IIS. Now I am getting an socket exception error that could be from a few thing, I just want to eliminate my options......
My question is do I have to publish the service as part of my deployment process or since I published the web application with a service reference attached to it I should be ok?
Here is my web config portion of the service as you can see there is a reference to localhost (this cant be good) how is this resolved?
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHSSWcfServices" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:49506/IHSSWcfServices.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHSSWcfServices"
contract="ServiceReference1.IHSSWcfServices" name="BasicHttpBinding_IHSSWcfServices" />
</client>
</system.serviceModel>
You do not have to publish the service as part of the deployment process for the application(otherwise, an ASP.NET application could never talk to an externally published service).
Just make sure that the service address you are trying to communicate with is the actual address of the hosted service (and not localhost, for instance, which would work on your machine, but not once it is deployed).
If you are writing the service and the client, the service does have to be deployed somewhere, and that somewhere must be accessible to the deployed location of the client. The deployment of the service is, however, independent of the deployment of the client.
Your system.ServiceModel section in config is clearly referencing the localhost. Try to change it to point to the actual IIS URL

ASP.NET - IIS7 Deployment Error 500 24 50 using WCF Web Service Binding w/ AD Groups

Background: I am getting a Internal Server 500 24 50 error after deploying an application that has compiled without errors on my local machine. The server that the application is deployed on has a ton of security and is running IIS 7.5 so I need to specify read and write access for every directory. This application uses windows authentication and a web service to populate drop down boxes via a proxy. I think there might be an issue connecting to the web service or an issue with the read/write security on the files, or an issue with the active directory authentication.
For some reason, Internet Explorer just displayed can't load webpage Error.
Error in Google Chrome:
500 – Internal Server Error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Log File Details:
#Software: Microsoft Internet Information Services 7.5
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken
2011-05-18 13:54:46 W3SVC1 FL-TPA-WEB-01 172.17.1.25 GET / - 80 -
172.17.1.25 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;
+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET4.0C;+.NET4.0E) - -
invitations.myagencyservices.com 500 24 50 1380 368 15
MSDN Defines the error at http://support.microsoft.com/kb/943891 as:
500.24 - An ASP.NET impersonation configuration does not apply in Managed
Pipeline mode.
Web.Config code:
<system.web>
<customErrors mode="Off" ></customErrors>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<trace enabled="true" pageOutput="true" />
<authentication mode="Windows"/>
<identity impersonate="true"/>
<authorization>
<allow users="alg\bmccarthy, alg\phoward" />
<allow roles="alg\ACOMP_USER_ADMIN" />
<allow roles="alg\ACOMP_user_AMG" />
<allow roles="alg\ACOMP_user_BIG" />
<allow roles="alg\ACOMP_user_NIS" />
<allow roles="alg\ACOMP_user_GLA" />
<allow roles="alg\ACOMP_user_PIP" />
<allow roles="alg\ACOMP_user_PSM" />
<allow roles="alg\ACOMP_user_PAM" />
<allow roles="alg\ACOMP_user_ANN" />
<allow roles="alg\ACOMP_user_AAM" />
<allow roles="alg\ACOMP_user_MWM" />
<allow roles="alg\ACOMP_user_GIM" />
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAcompService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://63.236.108.91/aCompService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IAcompService1" contract="aComp_ServiceReference.IAcompService"
name="BasicHttpBinding_IAcompService1" />
</client>
</system.serviceModel>
Any suggestions will be up-voted!
Thanks for looking!
The 500.24.50 Error occurs because ASP.NET Integrated mode is unable to impersonate the request identity in the BeginRequest and AuthenticateRequest pipeline stages. 500.24 is thrown if your application is running in integrated mode, validateIntegratedModeConfiguration is not declared or set to true, and your application has identity impersonate set to true.
Workaround
A. If your application does not rely on impersonating the requesting user in the BeginRequest and AuthenticateRequest stages (the only stages where impersonation is not possible in Integrated mode), ignore this error by adding the following to your application’s web.config:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
B. If your application does rely on impersonation in BeginRequest and AuthenticateRequest, or you are not sure, move to Classic mode.
C. remove from web.config which won't be effective in integrated mode anyway
Read more on Breaking Changes in IIS 7 from LEARN.IIS.NET
UPDATE:
Did a little more digging and you actually have the service mis-configured. This MSDN article explains how to configure basicHttpBinding for Windows authentication. Basically, the basicHttpBinding element needs to look like this:
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
Original answer:
Below is something to try from the information in this article. Since your service uses impersonation for authorization it looks like you'll need to use the ASP.NET classic mode pipeline configuration of the AppPool for this service. You may want to research how impersonation is supported in the new Integrated mode pipeline and see why your service is failing to comply with it since Integrated mode is prefered.
You will receive a 500 - Internal
Server Error. This is HTTP Error
500.24: An ASP.NET setting has been detected that does not apply in
Integrated managed pipeline mode.
This occurs because ASP.NET Integrated
mode is unable to impersonate the
request identity in the BeginRequest
and AuthenticateRequest pipeline
stages. Workaround
B. If your
application does rely on impersonation
in BeginRequest and
AuthenticateRequest, or you are not
sure, move to Classic mode.
Important: Make sure that you have installed ASP.NET on your machine; if not or if in doubt, run the following command:
> c:\Windows\Microsoft.NET\Framework\vX.X.XXXXX\aspnet_regiis.exe /i

Service Unavailable 503 + The HTTP service located at http://localhost/ProductsService/Service.svc is too busy

Hi I have been trying to solve my problem, however couldn't do anything about it.
The problem is
http://localhost/productservice/service.svc when type this address in my browser it gives me 503 Service Unavailable error
When I run my code from VS 2010 it gives me
The HTTP service located at http://localhost/ProductsService/Service.svc is too busy.
exception.
ProductService is running in the ASP.NET v4.0 integrated application pool with the ApplicationPoolIdentity.
I just got no idea what I need to do!
(Windows 7 Home & IIS7)
basicHttpBinding is used
the server side config is
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="AdventureWorksEntities" connectionString="metadata=res://*/ProductsModel.csdl|res://*/ProductsModel.ssdl|res://*/ProductsModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PINCHY\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
the client app.config is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IProductsService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:80/ProductsService/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProductsService"
contract="ProductsService.IProductsService" name="BasicHttpBinding_IProductsService" />
</client>
</system.serviceModel>
</configuration>
Any help will be much appreciated
Thanks
Had the same problem, but a different cause. In IIS (left side panel), click on Application Pools and make sure the ASP.NET version you've selected is actually running. Mine was off for some reason.
I just have the same issue. The issue for me turned out be an invalid password. My password recently changed and the app pool for IIS uses the old password. Once the password was updated the application worked again.
Hopes that help.
I also ran into the same problem and the solution is,
In IIS click on ProductsService website under default website. On the right side under actions pane click on advanced settings. Check the Enabled Protocol property the values for this property should be comma separated ex: http,net.tcp . Actually I had entered semi colon instead of comma and I used to get the same exception which you are facing. try replacing semicolon which comma. I think it should work.
Our team experienced the same issue, 503 Service Unavailable.
In our case, the application pool was fine, (the identity was set correctly and the app pool was started).
After some evaluation, we discovered a WCF based service was installed on the server that reserved port 80. Using the netsh http command we were able to see the url reservation.
netsh http show urlacl
Reserved URL : http://+:80/
The following link proved helpful:
http://blogs.msdn.com/b/webtopics/archive/2010/02/17/a-not-so-common-root-cause-for-503-service-unavailable.aspx
I kept getting the 503 error in IIS 7 running a .NET 4.0 website on localhost. I got rather smug about it because all I had to do was click on Application Pools in the left-hand pane where you see sites and application pools listed. Sure enough, the relevant application pool was always stopped and I just re-started it. However, today (the reason I came back to this question) this didn't solve the problem. In my case I have a website with some public pages, then 2 applications which are password-protected. Only one of the applications was giving the 503 error. I selected the application and clicked Advanced settings and realised that the problem was the application pool. It was pointing to the DefaultAppPool instead of the application pool for the overall website. When I corrected that, all 3 areas of the website began working normally again. So, to sum up, a 503 error may be caused by a stopped application pool. Just make sure you re-start the right application pool to get your website running again.

Resources