net.tcp service is unavailable for the protocol of the address - wcf

Our application is hosted in IIS 7.0. It exposes endpoints over net.tcp protocol. But we kept running into the following exception:
EndpointNotFoundException: The message could not be dispatched because
the service at the endpoint address
'net.tcp://localhost/xxx/service.svc' is unavailable for the protocol
of the address.
We have checked the following places for possible causes.
Windows Process Activation Service is running OK
Net.Tcp Listener Adapter service is OK.
Net.Tcp Port Sharing service is OK.
We made net.tcp binding for the web application.
The net.tcp protocol is enabled for the web application as below.
I have tried to reset the IIS after checking all the above places. Still not working.
This is killing me. Hope someone could give me some hints.
I have searched a lot. Seems this is a very common issue which hasn't be perfectly solved. I think it's time to end this pain in ass.
Many thanks!

It is hard to say but on what port are you trying to connect?
Make sure that port is available and nothing else is using it.
If you are using a proxy you should add the below as well:
......
<httpTransport
maxBufferPoolSize="4194304"
maxBufferSize="1048576"
maxReceivedMessageSize="1048576"
proxyAddress="http://127.0.0.1.:8888
useDefaultWebProxy="false"
/>
</binding>
</customBinding>

Related

wsDualHttpBinding works on LAN but doesn't work on internet

I have a wcf simple program that use wsDualHttpBinding. I put my server.exe on another computer (on my LAN network) and called a method via client. callback successfully called at client. Then I put my server.exe on my VPS server (on Internet) and run client.exe, client throws TimeoutException.
I use 9090 port for server listening. Also I turn off firewall on both side.
what's wrong?
please help, it's going me crazy.
EDIT:
Do both server and client need valid IP address?
Check your client's config . Try increasing the below settings:
<binding name="WSDualHttpBindingEndpoint"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
Verify that the Service Operation is being called & is returning in a timely fashion.
Have Service write to log when method is entered & exited.
Also verify port 9090 is not blocked.
Try to publish http metadata with metadata endpoint in your server.exe and open webservice page on client machine in browser.
I also recommend you to use nettcpbinding instead of wsDualHttpBinding even over the Internet because it's more stable, persistent channel and AFAIK wsDualHttpBinding requires two ports for normal duplex conversation (see ClientBaseAddress in client binding). Tcp needs one though
The problem has solved!
In duplex connections, both client and server need valid ip address.
I changed connection way. I used netTcp.
anyway tnx everyone.

WCF net.tcp port sharing on IIS 7 / WAS

I am new to wcf programming and I have been working on a small project and am having problems with net.tcp port sharing. I am using .net framework 4 and iis 7.
I have two wcf services (serviceA and serviceB) being hosted on our server in separate websites on IIS. Each website has its own .svc file, web.config and bin. If I have each of these services on different net.tcp ports then there is no problem and I can add the service reference to each of them from visual studio on my pc. The services run fine.
However we will soon be starting a project with many more services and we wish to avoid having to open a tcp port for each one so I have been trying to get serviceA and serviceB to port share. If I set them up on the same port then I can access the first service I add but when when I try to access the second service added to the same port i get the following error:
Metadata contains a reference that cannot be resolved:
'net.tcp://myserver/serviceB.svc'. 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 **. An
existing connection was forcibly closed by the remote host If the
service is defined in the current solution, try building the solution
and adding the service reference again.
I can not work out what is going wrong. I have done a lot of searching on the subject and I have made sure that the following services are running:
Windows Process Activation Service
Net.Tcp Port Sharing Service
Net.Tcp Listener Adaptor
In addition net.tcp is an enabled protocol in the website's advanced settings. My current best guess is that it might have something to do with how I have defined the net.tcp bindings in IIS manager. Both of my websites running their independant services have the following: 808:*(net.tcp) is this correct?
As i said earlier the tcp services run fine if set up on two separate ports so the issue must be related to the port sharing. Very grateful for any advice
OK I found the problem I was having. In IIS I had set up each service as its own website and was trying to get those different websites to port share. This would not work.
However I found that if I set up just one website and then added my services as seaprate applications under the website then the port sharing will work. This approach lets me have multiple services as applications under one website.
Check this.
This can be helpful to you.
http://himanshudesai.wordpress.com/2011/06/03/multiple-wcf-services-on-a-single-port/
Hope this helps.

WCF service hosting using website other than "Default Web Site", default port, net.tcp

My basic question is for guidance hosting a WCF service in IIS7 (2008 R2) on the default net.tcp port of 808 on a website other than "Default Web Site". I have 4 sites each bound to a specific IP address. I would like my WCF services to be hosted within a site other than the default using port 808. What is the catch here? I want to understand this without just using another port to solve the issue if that would even be the case.
I created this running question/log of trying to figure this out yesterday, but I just didn't have much luck. I had to move the WCF services back to the default website and move the net.tcp binding from my desired website back to the default as well.
moved net.tcp WCF services from localhost to IP address on new site, services won't load
I access my services using the technique of:
MyServiceClient : ClientBase<IMyService>, IMyDataService
and within the methods of the client:
return base.Channel.MyOperation(request);
I rely on the WCF configs in web.config of the hosting projects providing the .svc file to properly connect me to the WCF services. If this is sub-optimal, I am willing to change.
A typical client configuration in web.config looks as such:
<endpoint name="myServiceClient" address="net.tcp://localhost/MyServiceWebHost/MyService.svc/tcpEndpoint" binding="netTcpBinding" bindingConfiguration="myServiceNetTcpBinding" contract="Contracts.ServiceContracts.IMyService" />
Thanks for any pointers.
Its rights issue. Right click on your new website --> then Edit Permissions. On properties window click security tab and Edit button. Then Add IIS_IUSRS and give Read & execute, List folder contents, Read permissions. Now you can host and connect net tcp on new website.

WCF No connection could be made because the target machine actively refused

I just implemented a simple WCF server using net.tcp.
First, I use 127.0.0.1 as server address and client able to connect the WCF service.
Everything is Ok. But when I try to use the internal IP 192.x.x.x I get an error:
No connection could be made because the target machine actively refused it
Any idea what may cause this?
Best Wishes
PS: I disabled auth on WCF. Even turn off firewall all...Not worked...
Well, I got this error message when I forgot to install necessary components. see link Configuring WCF Service with netTcpBinding
(summary of steps)...
Go to "Programs and Features" (usually in control panel)
Go to "Turn Windows features on or off"
(assuming VS2012) Go to ".NET Framework 4.5 Advanced Services"->"WCF Services"
Enable "TCP Activation"
Do you use 192.x.x.x on both client and server? I remember seeing an issue a while back in which for TCP the client and server names needed to match (something related to one of the message properties), so if you define the service with "localhost" and the client with <machine name> there would be a problem.
The physical client and service addresses can differ if the logical address is the same and the server endpoint has been configured with a "listenUri" and the client behaviour is configured to use a <clientVia> address. In our case, this is required in for our proxy/firewall configuration. In effect, the client calls the firewall and the server listens locally for a forwarded request.
For an IIS-hosted service, check the following:
The Application pool is started and looks correct (.NET 4 etc/security)
For NET.TCP, ensure the "Allowed Protocols" in the Web Site/Application (via advanced settings) are configured correctly: e.g. http,net.tcp
For a non-IIS hosted service, you may need to configure a Namespace Reservation (URLACL). http://msdn.microsoft.com/en-us/library/ms733768.aspx
Also ensure the appropriate Windows Services are running, e.g. Net.Tcp listener.
If you're running from within visual studio in debug mode, ensure your solution port numbers match. I have seen several instances where I had Properties>Web>Auto-Assign Port - selected and the endpoint from, in this case my silverlight app, didn't match the port auto generated. I usually change the port to 1318 in my .web.
Today I found out that this error will also show up if you have a circular reference in your WCF Service Class. I had a method that was calling itself infinitely and causing this error message, which led me here.
So if none of the other suggestions work, check your code to see if you're doing any recursive functionality and make sure you're not caught in an infinite loop.
I resolved this issue by either commenting this setting in the application configuration:
<defaultProxy>
<proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
</defaultProxy>
or, running Fiddler which would take the WCF call at 127.0.0.1 and then forward it.
The complete scenario is, I encountered the same issue with WCF calls made to one of the service. The calls would fail with top level error message "There was no endpoint listening at http://LinuxIP:Port/...", and service trace viewer log showing inner exception to be "No connection could be made because the target machine actively refused it 127.0.0.1:8888
".
The reason was that I had put this configuration in my application to capture the outgoing traffic in Fiddler. If this configuration is in place then the Fiddler needs to be running for the WCF calls to make it to the intended destination. If Fiddler is not running this error will be there. Comment this setting in such scenarios, and the WCF call will go to the destination.

Hosting Multiple TCP WCF service Endpoints on single Port

I am hosting 3 WCF services inside windows services.Each WCF service contains Multiple endpoints. Right now, i am host all my endpoints thru TCP binding on different ports.
Is there any way to host all these end points from different wcf services on same port?
Sure is! You can use the Net.TCP Port Sharing service.
Net.TCP Port Sharing on MSDN
I just looked into that, out of curiosity. The behavior I discovered seems so strange that I almost don't want to put it here. But it worked in my case, so maybe it's doing the same for you:
I am getting the AddressAlreadyInUseException when I'm trying to host 2 services (i.e., 2 separate ServiceHost instances) on the same net.tcp port with portSharingEnabled="True" set on the netTcpBinding for both. That happens with or without the Net.Tcp Port Sharing Service running. The exception is thrown even if I only start one of the services (and I verified via netstat that there was no other listener on that same port on the machine, plus, I ran the app with elevated privileges).
Now, the funny thing is, the AddressAlreadyInUseException is not thrown when I set PortSharingEnabled = False, and yet both services are fully working!! Once again, with or without the Port Sharing Service running. I could even successfully connect to those services from a different machine.
An important note to make, however, is that the above only applies if the services are hosted within the SAME PROCESS! It does blow up if I try to start another instance of the app that's listening on the same port, but a different base address. But I'm assuming you're hosting those 3 WCF services inside the same Windows Service?
So, even though it doesn't seem right, my answer would be to disable PortSharingEnabled and see if it works with different BaseAddresses on the same port (provided they're all inside the same process).
As far as I know you not only have to enable port sharing on the configuration (or via code), you also have to manually start the Windows Port Sharing service.
That's the reason why I (having similar problem) didn't want to use port sharing, to make it easier for deployment rather than having to mess with other things the user may or may not know.