2016-03-25 35 views
0

Uygulamam, bir aygıtın bazı dönemlerinde Geçersiz URI'ye göre aşağıdaki hatayla çöküyor: Geçersiz bağlantı noktası belirtildi. Sorun şu ki, buna neden olan belirli bir yöntem bulamıyorum. Ve bazı Alman Ağ Bölgesinde sadece 1 cihazda çöküyor. Yığın İzlemesi yalnızca şu iletiyi gösterir:Geçerli domain_UnhandledException System.UriFormatException stacktrace yakalanamıyor

Current domain_UnhandledException. Stack trace: System.UriFormatException: Invalid URI: Invalid port specified. 
    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) 
    at System.Uri..ctor(String uriString) 
    at HttpServer.HttpClientContext.OnRequestLine(Object sender, RequestLineEventArgs e) 
    at System.EventHandler`1.Invoke(Object sender, TEventArgs e) 
    at HttpServer.Parser.HttpRequestParser.OnFirstLine(String value) 
    at HttpServer.Parser.HttpRequestParser.Parse(Byte[] buffer, Int32 offset, Int32 count) 
    at HttpServer.HttpClientContext.OnReceive(IAsyncResult ar) 
    at System.Net.LazyAsyncResult.Complete(IntPtr userToken) 
    at System.Net.ContextAwareResult.CompleteCallback(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Net.ContextAwareResult.Complete(IntPtr userToken) 
    at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) 
    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) 
    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 

Bazı fikirleri bulabilir miyim, çakışma kaynağını nasıl bulabilirim?

+0

Biz kaynak kodunu görmek gerekir ve fiili bağlantı noktası numarası (hata iletisinin konusunu) soruna neden olduğunu. –

+0

Kilitlenme, geçersiz bir URI oluşturmaya çalışan "HttpServer.HttpClientContext.OnRequestLine" dizinindedir. Şimdi, hangi HttpServer’dan bahsediyoruz? Bir "HttpClientContext" özelliği içermediği için, 'System.Web.Http' içinde 'HttpServer' mevcut olamaz. Kodunuz hangi platformda çalışıyor, ne tür bir uygulama? –

+0

Kaynak kod yardımcı olmayacaktır çünkü büyük bir App - bir wpf oyuncusu için hizmet olarak çalışıyor. Uygulama, x86 ve Windows 7'de çalışıyor. Sorunun Genel Kurul olduğunu düşünüyorum HttpServer.dll, v1.0.0.0 –

cevap

0

Bulunan yeni bilgilerini: https://github.com/duplicati/httpserver/blob/master/HttpServer/HttpClientContext.cs

private void OnRequestLine(object sender, RequestLineEventArgs e) 
     { 
      _currentRequest.Method = e.HttpMethod; 
      _currentRequest.HttpVersion = e.HttpVersion; 
      _currentRequest.UriPath = e.UriPath; 
      // Initialize _currentRequest.Uri to a synthesized path. This will be the final value if the host header is not sent 
      string authority = _localEndPoint.Address.ToString(); 
      if (_localEndPoint.Port != 80) authority += ":" + _localEndPoint.Port; 
      _currentRequest.Uri = new Uri((IsSecured ? "https://" : "http://") + authority + e.UriPath); 
     } 
+0

Bu kod, IPv6 adreslerinde başarısız olabilir, bu sizin sorununuz olabilir. IPv6 adresleri için, bu kodun yapamadığı port numarasını dahil etmek için adres kısmı parantez [] ile çevrelenmelidir. –

+0

İyi Fikir! HttpListeners dinamik olarak oluşturulduysa, bunu nasıl engelleyebilirim? (( –

+0

Ya yazara başvurun ve onların lanet kodunu düzeltin veya (kendinize bir çekme isteğinde bulunun) ağ kullanıcılarınızdan IPv6 IPv4 kurmasını isteyin. uygulamanızın IPv6 ile ilgili olduğunu belirten bir tünel. Bunun ötesinde, bu sitenin kapsamının biraz ötesinde olan uygulama mantığınızı yeniden yazmanız gerekir. –