简体   繁体   English

WCF服务调试期间出现异常异常

[英]Odd exception during debug of WCF service

This is a WCF service that is going to be hosted in IIS. 这是将在IIS中托管的WCF服务。 When I run debug from vs2010 my WCF client gets this exception: 当我从vs2010运行调试时,我的WCF客户端收到以下异常:

No connection could be made because the target machine actively refused it 由于目标机器主动拒绝连接,因此无法建立连接

The service URL is the the one dynamically assigned by visual studio, and the WCF service is being run in VS. 服务URL是Visual Studio动态分配的URL,并且WCF服务正在VS中运行。 The odd thing, this exception is actually never passed to my application, I only ran in to it when I started noticing lines like this in the output window: 奇怪的是,此异常实际上从未传递给我的应用程序,只有在开始在输出窗口中注意到这样的行时,我才遇到它:

The thread '' (0xa5c) has exited with code 0 (0x0). 线程''(0xa5c)已退出,代码为0(0x0)。

Each time that was thrown in the output window, a System.Net.SocketException would occur. 每次在输出窗口中抛出该异常时,都会发生System.Net.SocketException Why would a VS hosted WCF service be unreachable? 为什么VS托管的WCF服务无法访问?

This is a .NET 4.0 WCF service and client 这是一个.NET 4.0 WCF服务和客户端

UPDATE I thought i should describe this a little more. 更新我认为我应该对此进行更多描述。 The client is making a single call every 1 second on a timer. 客户端每1秒钟在计时器上拨打一次电话。 I use a flag to determine if the call is complete so i dont overlapp. 我使用一个标志来确定呼叫是否完成,所以我不重叠。 Just to emphasize, this error is never actually passed to my client. 只是要强调,此错误实际上从未传递给我的客户。 My client behaves as if the call is successful. 我的客户的行为就像呼叫成功一样。 The only reason I even know that the SocketException is occuring is because I used the VS options to break at Exception. 我什至知道SocketException发生的唯一原因是因为我使用VS选项在Exception处中断。

Where is the SocketException thrown, in the client app or the service? 客户端应用程序或服务中的SocketException抛出在哪里? It sounds like the thread is a worker thread being spun up to service the request, so that would be normal...and if the socket exception occurs in the client after the worker thread terminates without a reply, I would put the debugger on the service code to see if it's able to complete the request successfully. 听起来好像该线程是一个为响应请求而被启动的工作线程,所以这是正常的……如果在工作线程终止而无应答后客户端中发生套接字异常,我会将调试器放在服务代码,以查看它是否能够成功完成请求。

There are a number of common culprits. 有许多常见的罪魁祸首。

1) The port has not been opened in the firewall. 1)防火墙中的端口尚未打开。

2) The WCF endpoint code is throwing an exception at startup, often this can be a permissions issue or a missing dll. 2)WCF终结点代码在启动时引发异常,通常可能是权限问题或缺少dll。

3) The Address, Binding or Configuration is not identical on the endpoint and the client. 3)端点和客户端上的地址,绑定或配置不相同。

The error you received is a TCP error, not a WCF error. 您收到的错误是TCP错误,而不是WCF错误。 Here are some things to check: 这里有一些要检查的东西:

  1. If you are running service and client on the same machine (dev/staging), try using 127.0.0.1 rather than localhost when addressing the service 如果您在同一台机器上运行服务和客户端(开发/登台),请在寻址服务时尝试使用127.0.0.1而不是localhost

  2. Double-check the port that the service is running on and make sure there are no conflicts. 仔细检查运行服务的端口,并确保没有冲突。

  3. Also make sure that you are addressing the correct port in your calls from the client. 另外,请确保您要在从客户端进行的呼叫中寻址正确的端口。

The thread '' (0xa5c) has exited with code 0 (0x0). 线程''(0xa5c)已退出,代码为0(0x0)。

This is normal and only pertains to a worker thread finishing its work. 这是正常现象,仅与完成工作的工作线程有关。

No connection could be made because the target machine actively refused it 由于目标机器主动拒绝连接,因此无法建立连接

Either the binding referes to another machine to the port is wrong. 绑定引用到另一台机器端口错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM