Thursday, December 20, 2012

WCF Service Hosted in Windows Service over net tcp

WCF Service Hosted in Windows Service over net tcp

In my project I have one WCF Service which is hosted in a Windows Service. I hosted the WCF Service in Windows Service over netTCPBinding and Installed Windows Service. To access WCF service in my silverlight project I have added service reference of wcf. But, when I am calling a method in WCF Service am getting the following error :

Could not connect to net.tcp://localhost:8732/WCFHost/.
The connection attempt lasted for a time span of 00:00:03.2951885.
TCP error code 10013: An attempt was made to access a socket in a way forbidden by its access permissions..
This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access. You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.

Please help me out.

Answers & Comments...

Answer: 1

use basicHttpBinding instead of netTCPBinding

by : user592040http://stackoverflow.com/users/592040

Answer: 2

For same-machine connections rather make use of Named Pipe bindings.

It might help if you showed us your service and client side endpoint configurations.

EDIT: After reading up a bit on the error you're getting (here among other sites), try changing the port number from 8732 to something between 4502-4534 as the error message suggests.

by : tobias86http://stackoverflow.com/users/663970

Answer: 3

Keep same protocols at both the server and client end. May be your are calling the service with different protocols. Also check if your are using nettcp, your are having access to the machine where service is hosted.

by : Gauravhttp://stackoverflow.com/users/720429

Answer: 4

This is a really annoying error, took a lot of my time and in the end it turned out to be something elementary. I tried all the solutions proposed in various articles/forums and ultimately the fix for me was 2 things.

1.Include the clientaccesspolicy.xml file in the ROOT of your Default website in IIS (I'm assuming you were trying to consume the service hosted in IIS 7). Click on default website and the 'Explore' and place the clientaccesspolicy.xml there. The contents of you policy file should be this:

<?xml version="1.0" encoding="utf-8" ?> <access-policy>   <cross-domain-access>     <policy>       <allow-from http-request-headers="*">         <domain uri="*"/>       </allow-from>       <grant-to>       <resource path="/" include-subpaths="true"/>          <socket-resource port="4502-4534" protocol="tcp"/>       </grant-to>     </policy>   </cross-domain-access> </access-policy> 

2.Give the IP address of the service host in the endpoint instead of the computer name or localhost in the ServiceReference.ClientConfig of my Silverlight appplication. So basically Instead of:

<endpoint address="net.tcp://localhost:4502/MyService.svc" ..... /> 

try this:

<endpoint address="net.tcp://192.168.1.7:4502/MyService.svc" ..... /> 

This post from Microsoft's Silverlight forums has a pretty helpful checklist of possible causes of the error.

by : Mohammad Sepahvandhttp://stackoverflow.com/users/189756




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog