Can not communicate with WCF Windows Service


P

Patricio

Hello,

I having trouble connecting to a WCF Service hosted in a Windows Service.
I implemented the Windows Service as explained here: http://msdn.microsoft.com/en-us/library/bb332338.aspx

Here are the scenarios:

1) If I self-host the WCF Service then I can access it from the host PC
and from remote PCs.

2) If I host the WCF Service in a Windows Service then I can access it
from the host PC but not from remote PCs.

I have tried running the Windows Service under different users with the same
result (LocalSystem, NetworkService, a domain user, a local administrator,
etc.)

The error I get is:

System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://<server>:8008/WcfService.
The connection attempt lasted for a time span of 00:00:20.8404150. TCP error
code 10060: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed
because connected host has failed to respond <IP>:8008. ---> System.Net.Sockets.SocketException:
A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond 10.5.22.194:8008
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress
socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri
uri, TimeSpan timeout)


My config for the self-hosting and the Windows Service is:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="<service name>">
<endpoint address="net.tcp://localhost:8008/WcfService"
binding="netTcpBinding"
bindingConfiguration="TcpBindingConfiguration"
contract="<contract name>" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "TcpBindingConfiguration">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>

I have set the security to "None" for now to make sure I am not running into
security issues.

Thank you for your help,
Patricio.
 
Ad

Advertisements

C

Colbert Zhou [MSFT]

Hello,

I follow the following documents and have quick tests in my side. I can
consume the WCF service that hosted in a remote Windows Service.
(http) http://msdn.microsoft.com/en-us/library/ms733069.aspx
(tcp) http://msdn.microsoft.com/en-us/library/cc949080.aspx

I think we need to check the following three points,
1. Make sure our Windows Service is started
2. Make sure we have changed the client configuration to align the server
address.
3. Make sure we specify the client credential like the following codes,

-----------Client Configurations-----
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService1"
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="Transport">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://YOURSERVERNAME:8523/Service1"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1"
contract="ServiceReference1.IService1"
name="NetTcpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

-----------Client Codes----------------
ServiceReference1.Service1Client client = new
ConsoleApplication1.ServiceReference1.Service1Client();
client.ClientCredentials.Windows.ClientCredential.UserName =
"abc";
client.ClientCredentials.Windows.ClientCredential.Password =
"abc";
Console.WriteLine(client.GetData(23));


Best regards,
Colbert Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
P

Patricio

Hello Colbert,

Thank you for your answer. Implementing the tcp sample I was able to find
my issues: 1) Firewall blocking the port, and 2) Security Mode set to "None"
in the client.

The code for the tcp implementation (http://msdn.microsoft.com/en-us/library/cc949080.aspx)
has a bug in Step5, item 6: the code "myServiceHost = new ServiceHost(typeof(Service1));"
will intantiate a WindowsService1.Service1 instead of WcfServiceLibrary1.Servide1
making the service fail to start (I am using VS2008). The right code is
"myServiceHost = new ServiceHost(typeof(WcfServiceLibrary1.Service1));".
I submmited the feekback for the bug.

Thank you,
Patricio.
 
Ad

Advertisements

C

Colbert Zhou [MSFT]

Hello Patricio,

Thanks for your feedback! I saw the problem in that document and am sorry
for not mentioning in my first reply. I will also report it internally.
Hopefully, the document writer engineer will fix it soon! :)


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top