WCF Client-Server Socket Timeout
I have both a Client and Server application that can communicate just fine
when run locally on the same machine through Visual Studio 2010. If I
compile the Server application and move it to a Windows XP VM hosted on
the same machine and post the client to it, I can make method calls
without any issues. When I move the same Server application to a separate,
physical machine on the same network I cannot call into the service.
I am hosting the service in the Server with this call:
host = new ServiceHost(typeof(ClientHealth));
host.Open();
And accessing it on the Client side with this code:
try
{
if (client.InnerChannel.State !=
System.ServiceModel.CommunicationState.Faulted)
{
client.ReportHealth(DataMinder.clientIpAddress,
DataMinder.clientName, DateTime.Now);
}
else
{
client = new ClientHealth.ClientHealthClient();
client.Endpoint.Address = new EndpointAddress("net.tcp://" +
DataMinder.serverIpAddress + ":" + DataMinder.serverPort + "/");
}
}
catch (Exception ex)
{
Debug.WriteLine("Failed to connect to host");
Debug.WriteLine(ex.Message);
}
I am receiving the error: "The socket connection was aborted. This could
be caused by an error processing your message or a receive timeout being
exceeded by the remote host, or an underlying network resource issue.
Local socket timeout was '00:04:59.9532000'."
Here is my client app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<section name="GenericForms.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="TournamentTracker.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="connectionString"
value="Server=192.168.1.7;database=tournamenttracker;uid=root;pwd=12345"/>
</appSettings>
<system.diagnostics>
<trace autoflush ="true" />
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messagelistener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\myMessages.svclog"></add>
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
logMalformedMessages="true"
maxMessagesToLog="5000"
maxSizeOfMessageToLog="2000">
</messageLogging>
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IClientHealth" closeTimeout="00:01:00"
openTimeout="00:05:00" receiveTimeout="00:10:00"
sendTimeout="00:05:00"
transactionFlow="false" transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="1000000" maxConnections="10"
maxReceivedMessageSize="1000000">
<readerQuotas maxDepth="32" maxStringContentLength="1000000"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="1000000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<!--<security mode="Transport">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>-->
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:10001/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IClientHealth"
contract="ClientHealth.IClientHealth"
name="NetTcpBinding_IClientHealth">
<identity>
<userPrincipalName value="Maelstrom\Josh" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="DeviceHealthService.DeviceHealth"
behaviorConfiguration="MetadataBehavior">
<endpoint address=""
binding="netTcpBinding"
contract="DeviceHealthService.IDeviceHealth"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:10001"/>
<add baseAddress="http://localhost:10002"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<applicationSettings>
<GenericForms.Properties.Settings>
<setting name="SqlDirectory" serializeAs="String">
<value>C:\TournamentTracker\</value>
</setting>
</GenericForms.Properties.Settings>
</applicationSettings>
</configuration>
Server app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connectionString"
value="Server=localhost;database=tournamenttracker;uid=root;pwd=12345"/>
</appSettings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ClientHealthService.ClientHealth"
behaviorConfiguration="MetadataBehavior">
<endpoint address=""
binding="netTcpBinding"
contract="ClientHealthService.IClientHealth"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:10001"/>
<add baseAddress="http://localhost:10002"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
No comments:
Post a Comment