我的应用在某个设备上的某些时段崩溃,但无效的URI出现以下错误:指定的端口无效。
问题是我找不到具体的方法导致这个问题。它只在德国一些网络区域的1台设备上崩溃。堆栈跟踪仅显示以下消息:
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)
我可以获得一些想法,我如何才能找到崩溃源?
答案 0 :(得分:0)
从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);
}