How to resolve WCF CommunicationException was unhandled - wcf

I have some problems.
the issue is CommunicationException error.
error message is
An error occurred while receiving the
HTTP response to
http://localhost:18080/WCFServices/TestService.
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.
I wrote below source code.
TestServiceClient client = new TestServiceClient();
TestSettings[] voltages = client.GetTestSettings();
Error message appears above tilt word.
I want to synchronize Main Application and Client Application.
Above error is Client Application.
My app.config file is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITestService" 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="209715200"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" 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://localhost:18080/WCFServices/TestService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITestService"
contract="TestServiceReference.ITestService"
name="WSHttpBinding_ITestService" />
</client>
</system.serviceModel>
</configuration>
ps. TestService is modified that is temporarily
please anyone.
thanks.
oh sorry, error occurred on "voltage"
I tried to increase maxsize and length.
but, it didn`t resolve this issue.
somebody help me.

Without seeing your server side config it's going to be hard to help you troubleshoot.
Having said that, one of the things you can do to get the real underlying exception (you're not seeing what's really going on) is to configure WCF Tracing. Just drop that config snippet in the config file on your server side, and look through the logs generated. That should point you to the real problem. Make sure to take it back out when you're finished.

Related

WCF Service msg Size Error

I've two separated module (web based GUI and WCF based Server) and I'm using WCF service reference to access some methods from my GUI to Server. The problem occurs when GUI requests data from Server and it sends huge amount of data to GUI; Maximum Message Size error exception is thrown!
I increased the message size in appropriate section tag in Web.config file and it temporarily worked, but when the data- that is always growing in my case- reaches to the maximum allowed size the error happens again! I know that the bottle neck is on GUI side!
How can I solve the issue and is there any way to make the GUI service reference to handle ever-growing data?
Here is my GUI web.config file:
<pre>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServerHelper" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="16777216" maxBufferPoolSize="524288" maxReceivedMessageSize="16777216" 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://172.16.16.7:123456/ServerServices" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServerHelper" contract="ServiceReference1.IServerHelper" name="BasicHttpBinding_IServerHelper"/>
</client>
</system.serviceModel>
</pre>
thanks for helping me...
You can set these values up to int.MaxValue. If that's still not enough for your return message, you should try to split your messages. After all, that would be a message of 2GB. Maybe SOAP is not the best way to transport such a beast.

Just another "An existing connection was forcibly closed by the remote host" issue

I'm trying to access a WCF service on a company network. I'm using the proxy and config file generated by svcutil. The code looks like this:
using (Client client = new Client())
{
client.Open();
client.DoStuff();
}
Client is the client class in the generated proxy code, meaning it's derived from System.ServiceModel.ClientBase and implements the Contract interface.
And the config file looks like this:
<configuration>
<system.serviceModel>
<client>
<endpoint address="net.tcp://Address"
binding="netTcpBinding"
bindingConfiguration="Config"
contract="Namespace.Contract"
name="name">
<identity>
<servicePrincipalName value="Host" />
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="Config"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<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="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
I get the exception "An existing connection was forcibly closed by the remote host" every time the code reaches client.Open(). What really bothers is that when I try it from another computer, there's no exception. And on top of that, the config file used to have Transport security which was changed to None, and the computer where it works still has the old config file with
<security mode="Transport">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
whereas on the first machine and the server it's
<security mode="None">
<transport clientCredentialType="None" />
</security>
What can cause this? I've read numerous other questions here regarding this exception, but none seemed to resemble my issue.
SOLVED! I have set the security options in the wrong place.
The service was self hosted with ServiceHost, and the Security property wasn't set, so it defaulted to something else than None.
Check your Security settings for this project on your IIS (you are using IIS right?). I think it still says authentication type Windows.

Sending larger object to WCF results in 400 Bad Request

I have a unit test that sends a moderately large object to a WCF service. If I pass null for that parameter, everything works fine. When I send a populated object, I get an HTTP 400 response.
WCF tracing shows this error:
The maximum message size quota for incoming messages (65536) has been
exceeded.
However, I have cranked up the size configuration parameters in app.config for the unit test project as follows:
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyAppService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
What am I missing in my configuration to raise the allowed message size above the 65536 seen in the error message?
UPDATE:
The web.config file for the web service host also sets the maxReceivedMessageSize to a large value (I think):
<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
If I understand your question correctly, you increased the size for 'maxReceivedMessageSize' in the unit test's app.config. Actually you should make this change in the app.config/web.config of the web service which you are calling from your unit test code. If you host your web service in IIS, then it will be web.config. If you host it in windows service, then you need to make the change in the app.config (which gets moved to your .exe.config file in your bin folder.

TCP Error Code 10060 when sending request to Oracle Service Registry from Windows WCF Client

Hi All I get below error when sending request to OSR (Oracle Service Registry) from a Windows WCF Client.
"Could not connect to http://xxxx:xx/registry/uddi/inquiry TCP error code 10060: A Connection attempt failed vecause the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond HostIPAddress:Port."
the inner exception is:
An exception of type 'System.ServiceModel.EndpointNotFoundException' occured in method 'handleReturnMessage' of class 'realProxy'.
Env Details:
WCF Client installed on mutiple remote computers connected via broadband.
OSR installed on Linux box ( I don't have any control on this).
WCF Client details:
.NET Framewrok 3.5 Win Form app.
Client config file showing OSR endpoint and binding details.
<basicHttpBinding>
<binding name="basHTTPBinding" 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>
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="basHTTPBinding" contract="XXXX" name="OSR" />
</client>
Please let me know any of your thoughts on why this error occurs. Please note that this occurs intermitently.
Thanks.
The reason most likely for this error could be network issue over VPN. We need to monitor the network availability on the prod site if we face such kind of issues.

BizTalk WCF Send Port error - The header 'CoordinationContext' was not understood

I have a WCF-WSHttp Send Port set up with Enable Transactions checked, and I'm getting the following error when a message is sent:
The header 'CoordinationContext' from the namespace 'http://schemas.xmlsoap.org/ws/2004/10/wscoor' was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding.
If I uncheck the Enable Transactions box, the message is processed successfully. Can anyone help me get this working with transaction support?
Here's the binding info from the service's web.config (transactionFlow is set to true):
<bindings>
<wsHttpBinding>
<binding name="serviceBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="true" 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="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Thanks in advance!
It could be a problem with the setup of MSDTC, see http://msdn.microsoft.com/en-us/library/ms752261.aspx
Also check the event log for MSDTC related errors.
Turns out the problem was with the service itself. Although the bindings were configured properly with transactionFlow="true", the service contract was missing the following attribute to explicitly allow transactions:
[System.ServiceModel.TransactionFlowAttribute(System.ServiceModel.TransactionFlowOption.Allowed)]