Mik*_*e_G 5 websocket .net-core
Microsoft.AspNetCore.Connections.ConnectionResetException: The client has disconnected
---> System.Runtime.InteropServices.COMException (0x80070040): The specified network name is no longer available. (0x80070040)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Server.IIS.Core.IO.AsyncIOOperation.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ReadBody()
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ReadAsync(Memory`1 memory, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at MyApp.Utility.Extensions.<>c.<<UseMyAppSocket>b__0_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
Run Code Online (Sandbox Code Playgroud)
我有一些客户抱怨使用 websocket 与我的 web 服务断开连接。他们使用 JS Angular 客户端进行连接。我有逻辑客户端在失败时重新连接,但客户报告它从未这样做,或者他们可以看到进行了多次尝试并失败。这个错误是否表明客户端断开连接是由客户端引起的?有什么办法可以确定吗?
我从https://dba.stackexchange.com/questions/149539/the-specified-network-name-is-no-longer-available中捏了这个,因为它为我解决了问题,但那篇文章并没有容易找到。
\n问题原来是一些长时间运行的查询,平均需要 20 秒,但有时需要 70 秒,比默认超时时间长,因此抛出异常。
\n对于长时间运行的查询
\n为连接到 SQL Server 的应用程序连接字符串实现更长的命令超时值。
\n例子
\n<connectionStrings> \n <add name="webconfigconnectionString" connectionString="server=SQLServerName;database=dbName;uid=u\xe2\x80\x8c\xe2\x80\x8bserName;password=ABC\xe2\x80\x8c\xe2\x80\x8b123;Connect Timeout=120" />\n</connectionStrings>\nRun Code Online (Sandbox Code Playgroud)\n这可能不是一个很好的解决方案,但在您弄清楚如何提高查询性能的同时,它至少应该停止失败。
\n用于 DNS 故障排除
\n虽然 DNS 不是我的问题,但我已经从 dba.stackexchange 答案中复制了这个,以防它对其他人有帮助。
\n作为创可贴和故障排除辅助工具,添加并输入应用程序服务器(不是 SQL Server)上的主机文件(位于 c:\\windows\\system32\\drivers\\etc)
\nSQLServerIPAddress SQLServerName\nRun Code Online (Sandbox Code Playgroud)\n例子:
\n172.16.0.5 ProductionSQLBox\nRun Code Online (Sandbox Code Playgroud)\n这样,SQL Server 名称将由主机文件解析,直到您找到名称解析发生的真正问题为止。
\n确保通过命令行从应用程序服务器 ping SQL 框来测试主机文件。或者,也可以使用控制面板中的 ODBC 管理器创建 DSN 并在那里测试连接。
\n| 归档时间: |
|
| 查看次数: |
6823 次 |
| 最近记录: |