Как получить конечную точку HTTP, а не TCP-код, выставленный для службы WCF, размещенной в Service Fabric? Я успешно получил образец, предоставленный Microsoft в WCF-based communication stack for Reliable Services, но использует конечную точку TCP. Я изменил CreateServiceReplicaListeners()
код, чтобы попытаться с помощью BasicHttpBinding
, но получить следующую ошибку:HTTP-конечная точка для службы WCF в Azure Service Fabric
Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus', HealthState='Warning', ConsiderWarningAsError=false.
Replica had multiple failures in API call: IStatelessServiceInstance.Open(); Error = System.InvalidOperationException (-2146233079)
The ChannelDispatcher at 'http://localhost:0/43a1f131-a650-46f7-8871-02cc9821e0d1/6428f811-6944-4097-bf4a-0538355a1cb5-131275909542555280/81291d44-3c65-4d9b-8e0c-17a731103b5f' with contract(s) '"ICalculator"' is unable to open its IChannelListener.
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener`1.b__0(IAsyncResult ar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__0.MoveNext()
код в вопросе:
/// <summary>
/// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
/// </summary>
/// <returns>A collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
{
SendTimeout = TimeSpan.MaxValue,
ReceiveTimeout = TimeSpan.MaxValue,
OpenTimeout = TimeSpan.FromSeconds(5),
CloseTimeout = TimeSpan.FromSeconds(5),
MaxReceivedMessageSize = 1024 * 1024,
};
binding.MaxBufferSize = (int)binding.MaxReceivedMessageSize;
binding.MaxBufferPoolSize = Environment.ProcessorCount * binding.MaxReceivedMessageSize;
return new[]
{
new ServiceInstanceListener((context) =>
new WcfCommunicationListener<ICalculator>(context, this, binding, "WcfServiceEndpoint"))
};
}
Пришлось использовать немного больше из приведенного вами примера, но этот пример отлично работает - спасибо! –