I have used WCF service to transfer large files in chunks to the server
for that i have reference this article http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
I have configured my application on IIS on my machine. Its work fine here. It allows upto 64mb file upload. But when we have published the site. It allows only maximum 30Mb file if i try to upload more than that i got error 404 - resource not found.
Here is the binding config i have used.
<basicHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="FileTransferServicesBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" messageEncoding="Mtom" maxBufferSize="65536" maxReceivedMessageSize="67108864">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
Please suggest to me if I am missing anything and if required more code please let me know
On your webserver did you adjust the maximum upload size?
Goto "Request Filtering" for the target app, Open the feature, on the right side choose "Edit Feature Settings", in the dialog select a size larger than 30000000 (the default).
If on your local box you were hosting in Cassini, or your local box had different limits this might occur.
Related
Previously I am sending file (less than 63 KB ) through WCF Rest service then it send successfully but when the file size is greater than 65 KB, it throws an exception. After that I configure the web.config file like below and it works fine.
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="10485760">
<readerQuotas/>
</binding>
</webHttpBinding>
</bindings>
Now i am sending 10 MB file and also increase the size in web.config file but got the same exception.
I added below configuration setting :
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxStringContentLength="525288"></readerQuotas>
</binding>
</webHttpBinding>
</bindings>
What is needed to fix this?
I guess you receive this error on client side. remember you have to set the max size at client side!!!
Read Derek's answer. Thats really helpfull.
Im using Silverlight with wcf for my application. When the page requests it goes to the service for the output. But if the response(database operation) takes a bit of time to provide the output then my silverlight page is getting crashed. Can any help me what is the problem.
Sounds like you need to set the timeout settings for the WCF service to be higher to cater for the potential delays. The timeout settings are usually set in the bindings defined in the
<system.serviceModel>
<bindings>
section of the config file.
You will need to make sure that the 'receiveTimeout' in the client config, and the 'sendTimeout' in the service config are set to appropriate values that are high enough to cater for your particular service's timings.
An example 'basicHttpBinding' for the client-side, with a 'receiveTimeout' of 1 minute, 30 seconds could look like this (the important item to note being the 'receiveTimeout'):
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBindingConfig" receiveTimeout="00:1:30">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
When i call an recevive activity in Workflow, it is showing timeout error after 1 minute.
I tried to increase the timeout by modifying the web.config as follows, but no use.
<bindings>
<basicHttpBinding>
<binding name="longTimeoutBinding" closeTimeout="10:01:00" openTimeout="10:01:00" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="10:10:00" sendTimeout="10:10:00" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
I have similar problem with one of WCF service also when it fectes large number of data.
Can anyone help me to find out what i am missing here.
Have you also set these values on the client side? It could be that the client gives up waiting for a reply.
Could you try and reduce the timeout to 15 seconds to verify that these configs are the ones that are used.
Could you also post the exception that you get
I'm using the binding configuration below for my upload service,
<binding name="FileUploadSTSBinding">
<security authenticationMode="UserNameOverTransport"
requireDerivedKeys="false"
keyEntropyMode="ServerEntropy"
requireSecurityContextCancellation="false"
requireSignatureConfirmation="false">
</security>
<mtomMessageEncoding/>
<httpsTransport
transferMode="Streamed"
maxReceivedMessageSize="2147483647"/>
</binding>
But with this setting, I'm not able to upload big files like more than 1mb, server response is bad request.
Any thoughts?
You need to set the maxRequestLength attribute as well for the upload to work. It can here found in the web.config file here:
<configuration>
<system.web>
<httpRuntime>
Check that the IIS app pool identity has the right to write to the temp folder to be able to temporarily store the incoming data.
On a production server (Windows Server 2003 SP2) I can connect to a remote WCF service with Internet Explorer 8: When I browse to the URL http://www.domain.com/Service.svc (where my service listens) I get the expected info page of the service displayed. Connection settings in Internet Explorer only specify "auto detect", proxy settings are disabled.
If I start a console application (built with WCF in .NET 4.0) on the same server which also tries to connect to the same WCF service it fails telling me that no endpoint was available listening on http://www.domain.com/Service.svc.
Configuration of the WCF client:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://www.domain.com/Service.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="Service.IMyService" name="WSHttpBinding_IMyService" />
</client>
</system.serviceModel>
<configuration>
With these settings I can communicate successfully with the remote service from my development machine.
Looking around for other options I found that I can specify to use the Internet Explorer proxy settings with:
<system.net>
<defaultProxy>
<proxy usesystemdefault="true" />
</defaultProxy>
</system.net>
It didn't work and I am not sure if I understood this setting really correctly. (My hope was that the WCF client will adopt the "autodetect" setting of Internet Explorer and then connect the same way to the service like the installed IE.)
I also had toggled the useDefaultWebProxy setting in the binding configuration between true and false with no success.
Now I am asking for help what I can do? Which settings might be wrong or missing? What could I test and how can I get more detailed error messages to better identify the problem?
Thank you in advance!
Edit:
Stack in Innerexception is saying:
System.Net.WebException: Connection to remote server could not be established
System.Net.Sockets.SocketException: Connection failed since the host didn't answer after a certain time span or the connection was faulted since the connected host didn't answer.
Although Internet Explorer can connect to the service without specifying a proxy address but only enabling the "auto detect" feature this doesn't seem to work with my WCF client when setting <proxy usesystemdefault="true" />. (Documentation says: This will pickup the Internet Explorer settings. But it doesn't work.) Finally the customer gave me a concrete proxy address and I have changed the binding in my client configuration the following way:
Changed: useDefaultWebProxy="false" (instead of true)
Added: proxyAddress="http://10.20.30.40:8080" (Edit2: Not only IP-address! The prefix with http:// is important! Otherwise it will throw new exceptions, see the follow-up question below.)
With this the WebException and SocketConnection disappeared and the Client seems to connect to the Service but I am having now the next issue when calling the first service operation. I will put this in an new question.
Edit: Here is the follow-up question:
Strange exception when connecting to a WCF service via a proxy server
Edit2: According to the answer in the follow-up question it is important to prefix the proxyAddress with http. (changed my answer now)
Did you maybe just introduce a typo into your address on the client??
address="http://www.domain.com/Service.scv"
Shouldn't that be
address="http://www.domain.com/Service.svc"
(.svc instead of .scv at the end) (confirmed as no typo in reality)
Also, this address would indicate your *.svc file is in the root of that machine - is that really the case?? Normally in IIS, your address will be made up of machine name, virtual directory where the *.svc file resides, and the *.svc file itself, so something like:
http://www.domain.com/ServiceDirectory/Service.svc
I am not sure how you are hosting your service, IIS?
I didn't see anything wrong really in the configuration, other than
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"/>
</security>
If you say that when you type in the address in the IE you see the service, then it is leading me to believe that it is security setting that are wrong. Try removing the security block form the client config file or where ever you have it and see if that works....
If it does, we might have it narrowed it down...
The issue here may have been as simple as the case of true vs True
<proxy usesystemdefault="True" />