2009-04-03 26 views
7

Tôi có một dịch vụ web đơn giản để cho phép các ứng dụng truy vấn CMDB của tôi. Các chức năng tôi gặp rắc rối với các công trình với một resultset nhỏ nhưng không thành công với một lớn hơn, chỉ ra rằng nó là một cái gì đó trong cấu hình dịch vụ WCF đang ngăn chặn nó thành công.Không thể hiểu thông báo lỗi WCF, trợ giúp cần thiết

Tôi có ứng dụng thử nghiệm WinForms đơn giản với Tham chiếu dịch vụ cho dịch vụ web và một hàm duy nhất gọi hàm đang được đề cập đến.

Tập kết quả nhỏ hơn trả về ~ 120KB xml, kết quả lớn hơn không thành công là ~ 2MB. Tôi đã thử tăng kích thước của maxReceivedMessageSize và maxStringContentLength mà không thành công.

Có một số cấu hình tôi đã bỏ lỡ không? Tôi sẽ mong đợi một thông báo lỗi chi tiết hơn nếu đó là vấn đề.

Cảm ơn trước,

Nick


Các lỗi được trả lại là:

System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. ---> 
System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly. 
    at System.Net.HttpWebRequest.GetResponse() 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    --- End of inner exception stack trace --- 

Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.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.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) 
    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 TestRig.CmdbDataService.ICmdbDataService.GetMonitors(String client) 
    at TestRig.CmdbDataService.CmdbDataServiceClient.GetMonitors(String client) in C:\Documents and Settings\nfoster\My Documents\Visual Studio Projects\Virtual Operations Manuals\Trunk\src\TestRig\Service References\CmdbDataService\Reference.vb:line 1480 
    at TestRig.Form1.btnGetServers_Click(Object sender, EventArgs e) in C:\Apps\Virtual Operations Manuals\Trunk\src\TestRig\Form1.vb:line 8 

Chức năng gọi điện thoại trong ứng dụng là:

Private Sub btnGetMonitors_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMonitors.Click 
    txtResults.Text = String.Empty 
    Dim proxy As CmdbDataService.CmdbDataServiceClient = Nothing 
    Try 
    proxy = New CmdbDataService.CmdbDataServiceClient("WSHttpBinding_ICmdbDataService") 
    Dim monitors As TestRig.CmdbDataService.ConfigurationItems = proxy.GetMonitors(txtClientName.Text) 
    proxy.Close() 
    For Each monitor In monitors 
     txtResults.Text &= monitor.Name & " (" & monitor.TypeName & ")" & vbCrLf 
    Next 
    txtResults.Text &= monitors.Count & " monitors returned" 
    Catch ex As Exception 
    If Not IsNothing(proxy) AndAlso proxy.State <> ServiceModel.CommunicationState.Closed Then proxy.Abort() 
    txtResults.Text = ex.ToString 
    Finally 
    proxy = Nothing 
    End Try 
End Sub 

On t est giàn khoan bên app.config chứa serviceModel sau:

<system.serviceModel> 
    <diagnostics> 
     <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <behaviors /> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_Default" closeTimeout="00:05:00" 
      openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" 
      maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600"> 
      <readerQuotas maxDepth="104857600" maxStringContentLength="104857600" 
      maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/CmdbServices/DataService.svc/soap12" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Default" 
     contract="CmdbDataService.ICmdbDataService" name="WSHttpBinding_ICmdbDataService"> 
     <identity> 
      <userPrincipalName value="MyMachine\ASPNET" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

và ở phía bên dịch vụ web.config là:

<system.serviceModel> 
    <diagnostics performanceCounters="Default"> 
     <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="MyCorp.Cmdb.Services.DataService.CmdbDataService"> 
     <endpoint address="soap12" binding="wsHttpBinding" contract="MyCorp.Cmdb.Services.DataService.ICmdbDataService" /> 
     <endpoint address="soap11" binding="basicHttpBinding" contract="MyCorp.Cmdb.Services.DataService.ICmdbDataService" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
+0

tôi sẽ cố gắng tăng giá trị thời gian chờ. –

Trả lời

15

Một đồng nghiệp của tôi vừa mới chỉ cho tôi số this blog post nơi thủ phạm thực tế là thuộc tính maxItemsInObjectGraph trong hành vi điểm cuối.

Bumping những lên đã giải quyết được vấn đề, tôi phải vừa đi qua ngưỡng mặc định của 65536: D

Rất vui được gặp các thông báo lỗi chỉ cho bạn đi đúng hướng :(

Cheers .. ..

Ngoài ra:. bạn có thể nhận được lỗi này vì một trong những phương pháp web của bạn đang sử dụng lớp đó không phải là một lớp [DataContract]

+0

Lưu trữ web của bài đăng trên blog: http://web.archive.org/web/20071013175610/http://blogs.conchango.com:80/merrickchaffer/archive/2007/09/19/WCF-System.Net.WebException_3A00_-The-underlying-connection-was-closed_3A00_-The-connection-was-closed-unexpectedly.aspx –

0

CẬP NHẬT: OK, tôi thấy rằng bạn đã có truy tìm bật . Bạn đã xem xét các dấu vết WCF chưa?

+0

Tôi đã xem qua các dấu vết nhưng tôi thấy chúng thực sự khó giải mã, WCF không phải là khu vực chính của tôi. Ngoại lệ được liệt kê trong đó nhưng chi tiết chính xác như trong ngoại lệ ban đầu: ( – Nick

0

Cố gắng thêm bắt này trong mã phía khách hàng:

catch (CommunicationException commProblem) 
{ 
    Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); 
    Console.Read(); 

} 
Các vấn đề liên quan