【问题标题】:HttpListenerException in local cluster本地集群中的 HttpListenerException
【发布时间】:2016-01-10 19:25:10
【问题描述】:

我有两个单独的(两个单独的 Visual Studio 解决方案)服务结构应用程序。两者都是该示例中的简单 Web api 服务:

https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-communication-webapi/

我在本地集群中部署了我的第一个示例并且它正在运行。然后我在同一个本地集群上部署了第二个(类似的)示例,我得到了以下异常:

System.Reflection.TargetInvocationException was unhandled by user code
  HResult=-2146232828
  Message=Ein Aufrufziel hat einen Ausnahmefehler verursacht.
  Source=mscorlib
  StackTrace:
       bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       bei Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
       bei Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
       bei Microsoft.Owin.Hosting.WebApp.Start(String url, Action`1 startup)
       bei WebApi.Service.OwinCommunicationListener.OpenAsync(CancellationToken cancellationToken) in C:\...\WebApi.Service\OwinCommunicationListener.cs:Zeile 40.
       bei Microsoft.ServiceFabric.Services.Runtime.StatelessServiceBase.<OpenCommunicationListenersAsync>d__a.MoveNext()
  InnerException: 
       ErrorCode=183
       HResult=-2147467259
       Message=Fehler beim Abhören von Präfix http://+:80/webapp/, da es mit einer vorhandenen Registrierung auf dem Computer in Konflikt steht.
       NativeErrorCode=183
       Source=System
       StackTrace:
            bei System.Net.HttpListener.AddAllPrefixes()
            bei System.Net.HttpListener.Start()
            bei Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
            bei Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
       InnerException: 

之后,我删除了本地集群并创建了一个新集群。然后我刚刚部署了第二个应用程序,它仍然没有运行。我也重新启动了计算机,但仍然无法正常工作。然后我再次尝试了第一个应用程序并且它正在运行。

我不知道我还能做什么?

【问题讨论】:

    标签: azure asp.net-web-api self-hosting httplistener azure-service-fabric


    【解决方案1】:

    好的,我自己解决了这个问题。

    由于某种原因,应用程序参数丢失:

    <Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/WebApplication" xmlns="http://schemas.microsoft.com/2011/01/fabric">
       <Parameters>
          <Parameter Name="WebApiService_InstanceCount" Value="1" />
       </Parameters>
    </Application>
    

    【讨论】:

    • 我的德语有点生疏,但我已经多次看到这个异常,告诉你为什么添加该参数可以解决问题。它在同一台机器上创建服务的多个实例,这意味着您有多个进程都在同一个端口上竞争。添加该参数将实例数限制为 1。
    猜你喜欢
    • 2018-11-26
    • 1970-01-01
    • 2017-10-16
    • 2021-04-17
    • 2018-12-27
    • 2021-01-23
    • 1970-01-01
    • 2019-07-08
    • 2019-01-20
    相关资源
    最近更新 更多