我有一个客户端和服务器(它拥有wcf服务)应用程序。服务器应用程序托管在azure中。通过控制台应用程序,我将向wcf服务发送一些大量数据,然后我将处理并将数据保存到azure数据库中。
但是我在控制台应用程序中收到以下错误
"服务器未提供有意义的回复;这可能是由合同不匹配,过早的会话关闭或内部服务器错误引起的。"
我知道已经提出了很多关于这个错误的问题,我尝试了很多不同的解决方案,但没有一个能为我工作。
客户端代码 - Program.cs
var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
var serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
var clientSection = serviceModelSectionGroup.Client;
var testEndpoint = clientSection.Endpoints[0];
//Web service post data
Binding binding = new BasicHttpBinding(testEndpoint.BindingConfiguration);
var endpointAddress = new EndpointAddress(testEndpoint.Address.ToString());
var beh = new EndpointBehaviorElement(testEndpoint.BehaviorConfiguration);
using (var testService = new LoadServiceClient(binding, endpointAddress))
{
var response = testService.ReceivePostLoads(datas);
testService.Close();
return response;
}
客户端配置:
<system.serviceModel>
<client>
<endpoint address="http://kafreight.azurewebsites.net/Services/LoadService.svc/LoadService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttp_Binding" contract="PostLoads.ILoadService"
name="Default" behaviorConfiguration="ServiceViewEventBehavior"/>
</client>
<bindings>
<basicHttpBinding>
<binding name="basicHttp_Binding" receiveTimeout="00:25:00" sendTimeout="00:25:00" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" openTimeout="00:25:00" closeTimeout="00:25:00">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceViewEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
服务器端配置:
<services>
<service name="FreightRover.Services.LoadService"
behaviorConfiguration="longTimeoutBehavior">
<endpoint name="Default"
address="LoadService.svc"
binding="basicHttpBinding"
bindingConfiguration="longTimeoutBinding"
contract="FreightRover.Services.ILoadService"
behaviorConfiguration="ServerEventBehavior" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name ="longTimeoutBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" receiveTimeout="00:25:00" openTimeout="00:25:00" closeTimeout="00:25:00">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="longTimeoutBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ServerEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="FreightRover.Services.LoadService"
behaviorConfiguration="longTimeoutBehavior">
<endpoint name="Default"
address="LoadService.svc"
binding="basicHttpBinding"
bindingConfiguration="longTimeoutBinding"
contract="FreightRover.Services.ILoadService"
behaviorConfiguration="ServerEventBehavior" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name ="longTimeoutBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" receiveTimeout="00:25:00" openTimeout="00:25:00" closeTimeout="00:25:00">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="longTimeoutBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ServerEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
注意:
我注意到在服务器端进程正在运行,但客户端在服务器返回响应之前抛出错误。我没有在服务器端获得任何例外,并且所有数据都已成功保存,但在客户端我收到错误&#34;服务器未提供有意义的回复&#34;。
对于少量数据,它工作正常,只有在我尝试处理大量数据时才会收到错误。
过去三天我一直在努力解决这个问题。请帮我解决这个问题。
我尝试了以下链接中提到的解决方案
WCF ERROR: The server did not provide a meaningful reply;
解决方案涉及安全模式=&#34;运输&#34;
在我的情况下,我不想为我的wcf服务配置任何安全性
新更新:
使用相同的上述配置,我在本地IIS中托管了服务器应用程序,并且它可以正常处理大数据,所以我猜问题只有在我们将应用程序托管在azure时才存在。