I am trying to consume a web service from a third party. Whenever the message that I send to the server passes a certain size, I am getting the following exception:
Unhandled Exception: System.ServiceModel.CommunicationException: An error occurred while making the HTTP request to https://host/path. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
I am pretty sure that the first message regarding HTTP.SYS is incorrect because it works if I decrease the message size.
This is the code of a successful call:
var request = new GreetingUploadRequest
{
msisdn = "12345678900",
personalGreetingVoiceData = File
.ReadAllBytes(@"d:\Temp\sample.wav")
.Take(48876)
.ToArray()
};
var response = service.GreetingUpload(request);
And this is the code of an unsuccessful call:
var request = new GreetingUploadRequest
{
msisdn = "12345678900",
personalGreetingVoiceData = File
.ReadAllBytes(@"d:\Temp\sample.wav")
.Take(48877)
.ToArray()
};
var response = service.GreetingUpload(request);
As you can see, the only difference is in the Take
- it is sending one byte more.
I have increased every setting I could think of, but to no avail:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="VmsGreetingUploadWSSoapBinding" closeTimeout="10:01:00"
openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="5147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpsBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="endPoint">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://host/path"
binding="basicHttpsBinding" bindingConfiguration="VmsGreetingUploadWSSoapBinding"
contract="ServiceReference1.VmsGreetingUploadWS" name="VmsGreetingUploadWS" />
</client>
</system.serviceModel>
Important: The server seems to be configured correctly, because I can send the full data from a SoapUI project!
What setting am I missing? How can I further troubleshoot this?
However, the message size can't be the only problem, because if I route the request through Fiddler 4 - and allow it to decrypt HTTPS traffic - it works even with big messages!