.net - EndpointNotFoundException 'Could not connect' 因为 'the target machine actively refused it' 通过 Fiddler 连接

标签 .net wcf proxy fiddler

我在尝试通过 Fiddler 路由我的 WCF 客户端请求时遇到问题。我在网上到处搜索,发现只有两个提到 Fiddler 在 WCF 服务配置为监听 IPv4 时出现问题,但启用了 IPv6。但是,虽然我的问题很相似,但这似乎不是我的问题。

我在连接到托管在 IPv4 端口上的服务时遇到问题。当我的绑定(bind)配置为使用 fiddler 代理时,我的 WCF 客户端会引发以下异常。我在 Fiddler 的选项中禁用了 IPv6 支持,并确保我的绑定(bind)已正确配置为使用代理。

异常报告:

System.ServiceModel.EndpointNotFoundException: Could not connect to http://campus.services.ecollege-labs.com/Entity/Foundation/v1.0/EducationalPartnerSvc. TCP error code 10061: No connection could be made because the target machine actively refused it 10.181.3.23:8888. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.181.3.23:8888 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() --- End of inner exception stack trace ---

Server stack trace: at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at IMS.EnterpriseServices.Facades.Campus.EducationalPartner.EducationalPartnerSvc.FindByClientString(String clientString) at IMS.EnterpriseServices.Facades.Campus.EducationalPartner.EducationalPartnerSvcClient.FindByClientString(String clientString) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades.Campus\Service References\EducationalPartner\Reference.cs:line 428 at IMS.EnterpriseServices.Facades.Campus.CampusEntityFacade.GetEPID(String clientString) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades.Campus\CampusEntityFacade.cs:line 37 at IMS.EnterpriseServices.Transformation.Domain.TransformationSvc.TransformCreateGroupRequest(createGroupRequestMessage message) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Transformation.Domain\TransformationSvc.cs:line 106 at IMS.EnterpriseServices.Facades.IMSFacade.TransformCreateGroupRequest(createGroupRequestMessage imsMessage) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades\IMSFacade.cs:line 113 at IMS.EnterpriseServices.Domain.TransformationAndEnrichmentCoordinator.ProcessCreateGroupRequestMessage(createGroupRequestMessage message) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Domain\TransformationAndEnrichmentCoordinator.cs:line 140 at IMS.EnterpriseServices.Facades.IMSFacade.<>c__DisplayClass1.b__0(Object o) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades\IMSFacade.cs:line 135



绑定(bind)配置:
<customBinding>
  <!-- Secured, WS-Security message signing and encryption, custom binding for IMS endpoints -->
  <binding name="customHttpSecuredNoWSA">
    <security
      defaultAlgorithmSuite="Basic128Rsa15"
      authenticationMode="MutualCertificate"
      securityHeaderLayout="Lax"
      includeTimestamp="false"
      keyEntropyMode="CombinedEntropy"
      messageProtectionOrder="SignBeforeEncrypt"
      messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
      requireSignatureConfirmation="false"
      requireSecurityContextCancellation="false"
      allowSerializedSigningTokenOnReply="true">
      <localServiceSettings detectReplays="false" />
    </security>
    <textMessageEncoding
      messageVersion="Soap11"
      writeEncoding="utf-8">
      <readerQuotas
        maxArrayLength="1048576"
        maxStringContentLength="4194304"
        maxBytesPerRead="4194304"
        maxNameTableCharCount="4194304"
      />
    </textMessageEncoding>
    <httpTransport
      maxBufferPoolSize="4194304"
      maxBufferSize="1048576"
      maxReceivedMessageSize="1048576"
      proxyAddress="http://my.host.name:8888"
      useDefaultWebProxy="false"
    />
  </binding>
</customBinding>

最佳答案

感谢 Jon Skeet 和 Paolo 的评论,我能够解决这个问题。似乎某些东西(可能是防火墙)正在干扰与我的主机名/IP 的连接。使用 127.0.0.1 有效,但是必须在 WCF 配置中指定如下:
proxyAddress="http://127.0.0.1.:8888"
请注意 127.0.0.1 环回地址末尾的额外句点。如果没有句点,WCF 会进行某种硬编码检查,以防止在本地环回中使用代理服务器。 (为什么微软会明确地在代理服务器使用中建立硬编码排除本地环回的功能,这超出了我的理解,但至少这个技巧有效。)

关于.net - EndpointNotFoundException 'Could not connect' 因为 'the target machine actively refused it' 通过 Fiddler 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3135048/

相关文章:

c# - Web 服务不断引用旧版本的 Entity Framework

wcf - worker 角色 WCF 性能

node.js - 在 NodeJS 中创建一个可以处理多个安全域的反向代理

git - 阻塞代理后面的私有(private) bower 。需要什么异常(exception)?

.net - 无法实例化类的代理。找不到无参数构造函数

c# - WCF 服务停止工作 10054 WSAECONNRESET 连接被对等方重置

c# - Essentials C# framework 3.5 书籍错误示例代码

linux - 配置代理由于iptables

c# - 将 UTF-16 字节数组编码为字符串字符 C# .NET

c# - 支持区域的 MemoryCache?