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

岁酱吖の 提交于 2019-12-04 05:31:40

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 there would be a problem.

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"

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:

  1. The Application pool is started and looks correct (.NET 4 etc/security)
  2. 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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!