gpt4 book ai didi

.net-core - .NET Core 3.1 Websocket 错误 : The specified network name is no longer available

转载 作者:行者123 更新时间:2023-12-05 06:10:46 29 4
gpt4 key购买 nike

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)

我有一些客户提示使用 websocket 与我的 web 服务断开连接。他们使用 JS Angular 客户端进行连接。我有逻辑客户端在失败时重新连接,但客户报告说它从来没有这样做过,或者他们可以看到多次尝试和失败。此错误是否表明客户端断开连接是在客户端引起的?有什么办法可以确定吗?

最佳答案

我从 https://dba.stackexchange.com/questions/149539/the-specified-network-name-is-no-longer-available 中提取了这个,因为它解决了我的问题,但是那篇文章不容易找到。

问题原来是一些长时间运行的查询,平均需要20秒,但有时需要70秒,比默认超时时间长,因此抛出异常。

对于长时间运行的查询

为连接到 SQL Server 的应用程序连接字符串实现更长的命令超时值。

例子

<connectionStrings> 
<add name="webconfigconnectionString" connectionString="server=SQLServerName;database=dbName;uid=u‌​serName;password=ABC‌​123;Connect Timeout=120" />
</connectionStrings>

这可能不是一个很好的解决方案,但它至少可以阻止失败,同时您可以找出如何提高查询性能的方法。

用于 DNS 故障排除

虽然 DNS 不是我的问题,但我从 dba.stackexchange 的答案中复制了这个,以防它对其他人有帮助。

作为创可贴和故障排除辅助工具,在您的应用服务器(而非 SQL Server)上的 c:\windows\system32\drivers\etc 上添加和访问主机文件

SQLServerIPAddress SQLServerName

例子:

172.16.0.5 ProductionSQLBox

这样,SQL Server 名称将由主机文件解析,直到您找到名称解析的真正问题。

确保通过命令行从应用程序服务器 ping SQL 框来测试主机文件。或者,也可以使用控制面板中的 ODBC 管理器创建 DSN,然后在此处测试连接。

关于.net-core - .NET Core 3.1 Websocket 错误 : The specified network name is no longer available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64285222/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com