Set WCF to listen only on LOCALHOST

Similar to the limitation of the Visual Studio Development Web Server (Cassini) that it is only servers on the local host, I have an implementation of the WCF service, which is only required on localhost.

I would not mind accessing other computers, except that the Windows firewall suggests that the program listen on an external network adapter. Since this is only necessary internally, I would prefer to restrict the configuration on the WCF server side so that it does not disable the firewall detector.

Is binding.HostNameComparisonMode = HostNameComparisonMode.Exact correct solution? I do not see how this is enough.

====

Like Cassini, this Service implementation is redundant for something else that requires network connectivity. The client can be configured to connect to a real server or a fake implementation running on the local host.

+7
wcf localhost
source share
2 answers

It depends on how you take it. If you are in IIS7 or WAS, WCF uses the IIS compliance mode. Otherwise, if you use HostNameComparisonMode.Exact , then yes, the host name will always be an important factor when matching. If the host name does not match, sending is usually not performed.

It should be noted that the exact is not 100% exactly accurate ... it still allows some changes in the host name. If you have a NetBios hostname and fully qualified DNS name, a match will still occur, since WCF treats the two as the same thing.

System.ServiceModel.BasicHttpBinding.HostNameComparisonmode

0
source share

I think you are approaching him wrong. You should use a named pipe binding that should support any messaging template that you use (it supports request-response, as well as the same concurrency and session state modes that WS supports).

In the MSDN section called "Select Transport" (highlighted by me):

When to use a transport with pipe names

A named pipe is an object in the kernel of the Windows operating system, such as a shared memory partition, which processes can use to communicate. named pipe has a name and can be used for one-way or duplex communication between processes on the same machine.

When communication between different WCF applications on one computer is required, and you want to prevent any message from another machine , then use named transport pipes. An additional limitation is the processes running from Windows. Remote Desktop may be limited to the same remote Windows desktop if they did not raise privileges.

This meets your exact requirements and should be nothing more than a configuration change.

+6
source share

All Articles