PC Review


Reply
Thread Tools Rate Thread

Can not communicate with WCF Windows Service

 
 
Patricio
Guest
Posts: n/a
 
      11th May 2009
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.


 
Reply With Quote
 
 
 
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      12th May 2009
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 ((E-Mail Removed), 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 Removed).

 
Reply With Quote
 
Patricio
Guest
Posts: n/a
 
      13th May 2009
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.

> 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 ((E-Mail Removed), 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 Removed).
>



 
Reply With Quote
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      14th May 2009
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 Removed).

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Intranet ASP Web App to communicate with ASP Web Service? Leo Violette Microsoft ASP .NET 2 21st Apr 2009 08:01 AM
Modem Unable to Communicate with Internet Service Provider =?Utf-8?B?SE1D?= Windows XP Help 3 9th Sep 2005 01:57 PM
How to communicate with Windows Service in C#? =?Utf-8?B?Q2hhcmxlcyBDaGlhbmc=?= Microsoft Dot NET Compact Framework 4 16th Nov 2004 08:48 PM
Communicate with .net service =?Utf-8?B?SmltIEJha2Vy?= Microsoft Dot NET 1 2nd Jul 2004 12:51 PM
Best way to communicate between Windows Service and GUI? Adam Clauss Microsoft C# .NET 4 5th May 2004 10:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 PM.