이 문제에 대한 토론이 많지만 가능한 해결책을 모두 시도했지만 여전히 서버에서 413 Request Entity Too Large 오류가 발생합니다.WCF 413 요청 엔터티가 너무 많음 - 자체 호스팅 된 WebHttpBinding
우리의 WCF 서비스는 Azure Worker 역할을 통해 자체 호스팅되며 IIS를 사용하지 않습니다. 우리의 구성의 모든 코드에서 지정됩니다
var host = new ServiceHost(searchEngine);
// Create binding
var binding = new WebHttpBinding(WebHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
var readerQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxDepth = 2147483647,
MaxNameTableCharCount = 2147483647
};
// Setting quotas on a BindingElement after the binding is created has no effect on that binding.
// See: https://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, readerQuotas, null);
binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
binding.SendTimeout = new TimeSpan(1, 0, 0);
// Add the service endpoint
var ep = host.AddServiceEndpoint(
typeof(ISearchEngine),
binding,
string.Format("https://{0}/SearchEngine", externalEndpoint));
ep.Behaviors.Add(new WebHttpBehavior());
// Increase the MaxItemsInObjectGraph quota for all operations in this service
foreach (var operation in ep.Contract.Operations)
{
operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 10000000;
}
return host;
그리고 이것은 우리의 클라이언트 구성입니다 - 또한 코드에 지정된 :
var binding = new WebHttpBinding(WebHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
var readerQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxDepth = 2147483647,
MaxNameTableCharCount = 2147483647
};
// Setting quotas on a BindingElement after the binding is created has no effect on that binding.
// See: https://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, readerQuotas, null);
binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
binding.SendTimeout = new TimeSpan(1, 0, 0);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var channelFactory = new ChannelFactory<ISearchEngine>(binding, endpointAddress);
channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());
// Increase the MaxItemsInObjectGraph quota for all operations in this service
foreach (var operation in channelFactory.Endpoint.Contract.Operations)
{
operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 10000000;
}
return channelFactory.CreateChannel();
내에서만 직감가 SSL (Secure Socket Layer) 연결에 문제가 될 수 있을까? IIS 관련 문제를 언급 한 기사가 있지만 자체 호스팅 서비스와 관련이 있는지는 잘 모르겠습니다.
많은 조언을드립니다.
UPDATE :
는 SSL 문제, I 일시적으로 비활성화 SSL 보라는 것을 내 직감을 확인하고 문제가 사라 보라.
이제 SSL이 문제를 일으키는 이유를 알아야합니다. 이 유사한 문제에 대한 문서의 공정한 비트이지만, IIS는 (우리가 자기 Windows 서비스에서 호스팅되는) 만 서비스를 호스팅에 관련된 :
IIS7 - (413) Request Entity Too Large | uploadReadAheadSize
사람이 거기에 상응하는 설정을하는 것 알겠습니까 자체 호스팅 WCF 서비스에만 적용됩니까?
감사합니다. 나는 또한 이것을 시도했지만 스트리밍 모드가 우리가 사용하고있는 기본 인증과 작동하지 않는다는 것을 발견했다. 즉, 우리의 데이터는 작습니다 : 100kb - 200kb, 그래서 나는이 문제가 스트리밍의 부족이라고 생각하지 않습니다. – antscode