【发布时间】:2012-06-07 00:22:39
【问题描述】:
在使用 WCF 客户端进行测试时,我的 wcf 服务出现问题。当我调试时,我看到数据从函数返回,但在响应过程中出错。有人可以帮我弄清楚我错过了什么吗?
这是我的服务和配置文件:
public List<PO> GetAllPOs()
{
var data = new List<PO>();
try
{
var manager = new EntityReaderManager<PO>(ConfigurationManager.AppSettings("FilemakerDB"]);
data = manager.GetEntityList();
}
catch (Exception ex)
{
ILogger logger = new Logger(typeof(FilemakerDataService));
logger.Error(ex.Message);
}
return data;
}
这里是配置文件:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
maxSizeOfMessageToLog="2147483647" />
<endToEndTracing propagateActivity="true" activityTracing="false"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="Custom.WSHTTPBinding.Configuration" closeTimeout="10:10:00"
openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
maxBufferPoolSize="655360" maxReceivedMessageSize="655360">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
<services>
<service behaviorConfiguration="Custom.ServiceBehavior" name="AerWorldwide.Service.Web.FilemakerData.FilemakerDataService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="Custom.WSHTTPBinding.Configuration"
name="Custom.WSHTTPBinding.Configuration" contract="AerWorldwide.Service.Web.FilemakerData.IFilemakerDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Custom.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
错误:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
【问题讨论】:
-
您遇到的错误是什么?
-
无法从传输连接读取数据:现有连接被远程主机强行关闭。在 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 在 System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) 在 System.Net.Connection.SyncRead (HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) 内部异常:远程主机在 System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 处强制关闭现有连接跨度>
-
我还发现endpoint里面有一个name值,我把它拿出来了。还是会报错
-
这意味着发生了一些未处理的异常。你能确保你的代码运行良好。您可以启用跟踪,也可以在 Visual Studio 中启用异常抛出(Debug => Exceptions => 用于 Common Langu 的滴答声......)。也许你的记录器不工作。要检查的另一件事是您尝试通过通道传递的数据量。它可能太大,您将不得不增加消息大小。
-
如果跟踪文件太大,我该如何查找?
标签: c# .net wcf exception-handling