WCF net.tcp not supported. (socketexception) - c#

I have a learning application that implements the most important endpoints in a sole service. I am implementing net.tcp + wsHttp + BasicHttp and WebHttp, They all work great except for net.tcp. When i access it through the browser it tells me the following:
The protocol 'net.tcp' is not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The protocol 'net.tcp' is not supported.
Seems like a fairly common problem as I researched through the internet and concluded that because I was on xp using it locally I can't. And when I do the request I get a Socketexception with connection refused code.
But then again I made another project with only net.tcp and its endpoints and bindings and it works! So it most likely means I am not using IIS. I'm still a beginner in wcf, it tells me it is hosted by WCF Service host.
Can someone explain to me what can I do to make it work on windows xp?
Thanks

Yes, you are correct - Net.TCP is not available on IIS 5.1 (Windows XP).
To use Net.TCP on an XP machine you have two hosting options:
Self-hosted service (you write the program that hosts the service, using ServiceHost
Windows Service hosted - your service is hosted in a Windows Service.
IIS - HTTP only.
Refer to Hosting Services for an overview and comparison of the various methods to host a WCF service.

Browsers (and therefore IIS serving them) use HTTP.
TCP is a lower level protocol that would require a custom client to communicate with (such as a Windows App). The WCF Service host is an utility that can host your service for you whilst debugging. Normally you would write a proper host (exe or Windows service).

Related

WCF net.tcp service enabled ports are accessible if Silverlight application is browsed using HTTP but inaccessible from HTTPS

I have a WCF Service hosted as a Windows Service in the server.
The endpoint is net.tcp endpoint. We are accessing the endpoints from a Silverlight application.
Problem is when we are trying to access the service from the web app while browsing the Silverlight application using HTTP it works fine. But when we try to do so removing HTTP binding from the Silverlight app from IIS and browse the app using HTTPS the service endpoints are unavailable and gets access permission error from Sockets. I am attaching the error screenshot below:
Could not connect to service. The connection attempt lasted for a time span of 00:00:01.0865926. TCP error code 10061: No connection could be made because the target machine actively refused it. 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.

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.
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.
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.
use basicHttpBinding instead of netTCPBinding

WCF self hosting and IIS

Does WCF self hosting, still uses IIS or some Virtual Server based on IIS.
Eg: After coding a very basic WCF host, it s possible to invoke an endpoint such as
http://localhost:9090/foo.svc
For example: invoking a WCF host via TCP, does that use IIS internally?
I m trying to avoid IIS due to another app i m using, which doenst work with IIS Threads. That s why asking. so i d like to manage my own AppDomain and threadpool rather than IIS.
Any recommendation?
Can i seperate hosting of WCF from IIS?
When you self-host, you are using not a shred of IIS at all. You don't need IIS on that machine - nothing.
WCF self-hosting will require the http.sys driver for its http-based communication - but that's all there is. There is absolutely no trace of IIS needed - none, zip, nada.
Self-hosting WCF also allows you to pick your own service addresses and use whatever suits your needs - there's no virtual directory and no *.svc file to be dealt with.
It depends on the bindings. if you do a BasicHttpBinding, then all the communication will be over HTTP.
As for hosting WCF, there is the test server that comes with Visual Studio that you can use (it runs as a service. It's called WcfSvcHost.exe), but I wouldn't recommend it for production. If you are just testing, then you could just launch the WCF in the Visual Studio debugger and use its address all you want (it will be http://localhost:1234/foo.svc in that case)
If you are looking for a production hosting, you can use WCF as a SOAP endpoint, and here there is a pretty good article over at The Code Project that talks about creating a service for self hosting

Silverlight Accessing WCF and CrossDomainAccessPolicy without IIS

I have a Windows Service that exposes a WCF service and so I'm not using IIS. I'm suddenly getting the famous SecurityException that mentions using a cross-domain policy when I try to access the service from a Silverlight app. However, since I'm not using IIS, does that mean I need to have a web server on the same port as my WCF service just to serve this file? Is there a better way to do it?
You can add another service with webHttpBinding (REST) that serves out ClientAccessPolicy.xml file. Then in your Windows Service, you can start that endpoint along with the other one so that Silverlight clients can get the cross-domain policy file. You can find more information in below links:
Step By Step - Using Silverlight to Access a WCF Service Hosted In a Console Application
Self hosted WCF service and enabling cross domain calls

WCF: "Failed to open System.ServiceModel.Channels.ClientReliableDuplexSessionChannel"

I currently have a WCF Service with a CallBack Contract (duplex), and when I use the application that makes use of it on my computer everything works fine, but when I try it from a different computer, it doesn't connect.
These problems started occurring once I switched to using this wsDualHttpBinding (for callbacks) because when I used wsHttpBinding everything worked fine.
Why is the web service not accepting requests from other computers? Is it some hosting settings that need to be modified?
As regards the logs, I am getting these:
alt text http://img17.imageshack.us/img17/4628/wcfissue.jpg
The open operation did not complete
within the allotted timeout of
00:01:00. The time allotted to this
operation may have been a portion of a
longer timeout
Failed to open System.ServiceModel.Channels.ClientReliableDuplexSessionChannel
Faulted
System.ServiceModel.Channels.ClientReliableDuplexSessionChannel
Faulted
System.ServiceModel.Channels.ServiceChannel
Failed to open
System.ServiceModel.Channels.ServiceChannel
The port is open on my router (both TCP and UDP) so that is not the issue.
As regards the Service Attributes, this is what I'm using:
Interface:
[ServiceContract(Name = "MusicRepo_DBAccess_Service",
CallbackContract = typeof(IOnlineUsersCallback),
SessionMode=SessionMode.Required)]
Service:
[ServiceBehavior(
ConcurrencyMode=ConcurrencyMode.Reentrant,
InstanceContextMode=InstanceContextMode.Single)]
[Update]
As regards Orion Edwards' post:
No Firewall
See point 1
Yes I can, because I have the port forwarded on my router
I'm using IIS to host the server.
The thing is, this problem started happening when I switched from wsHttpBinding (which was working fine) to wsDualHttpBinding (because I needed callbacks)
[Update]
I have now switched from wsDualHttpBinding to NetTcpBinding and for some reason, everything is working fine.
I have used this article to help me set up hosting on IIS, and thankully everything is working as expected, with callbacks.
I have now switched from wsDualHttpBinding to NetTcpBinding and for some reason, everything is working fine.
I have used this article to help me set up hosting on IIS, and thankully everything is working as expected, with callbacks.
It would help if you posted the server and client configuration settings.
Here's a summary of how the wsDualHttpBinding works from MSDN (emphasise mine):
The WSDualHttpBinding provides the
same support for Web Service protocols
as the WSHttpBinding, but for use with
duplex contracts. WSDualHttpBinding
only supports SOAP security and
requires reliable messaging. This
binding requires that the client has a
public URI that provides a callback
endpoint for the service. This is
provided by the clientBaseAddress
attribute. A dual binding exposes the
IP address of the client to the
service. The client should use
security to ensure that it only
connects to services it trusts.
This binding can be used to
communicate reliably through one or
more SOAP intermediaries.
By default, this binding generates a
runtime stack with
WS-ReliableMessaging for reliability,
WS-Security for message security and
authentication, HTTP for message
delivery, and a Text/XML message
encoding.
Things to check:
Windows Firewall
Your antivirus product's firewall
Can you telnet into the port from a remote machine?
Is your "server" running under the ASP.NET development server? That will only accept requests from localhosts - you need to self-host the server using ServiceHost or host it under IIS.

Categories