Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .Net Core,Eventhub:身份验证失败,因为远程方已关闭传输流_C#_.net Core_Azure Eventhub - Fatal编程技术网

C# .Net Core,Eventhub:身份验证失败,因为远程方已关闭传输流

C# .Net Core,Eventhub:身份验证失败,因为远程方已关闭传输流,c#,.net-core,azure-eventhub,C#,.net Core,Azure Eventhub,我正在开发EventHub的制作人。在部署到我们的测试环境后,它在本地工作正常-我收到错误“身份验证失败,因为远程方已关闭传输流。” Docker image:mcr.microsoft.com/dotnet/core/aspnet:3.1 使用的代码: await using (var producerClient = new EventHubProducerClient(connectionString)) { var

我正在开发EventHub的制作人。在部署到我们的测试环境后,它在本地工作正常-我收到错误“身份验证失败,因为远程方已关闭传输流。”

Docker image:mcr.microsoft.com/dotnet/core/aspnet:3.1

使用的代码:

await using (var producerClient = new EventHubProducerClient(connectionString))
                {
                    var eventData = new EventData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)));

                    var batch = await producerClient.CreateBatchAsync();
                    batch.TryAdd(eventData);
                    await producerClient.SendAsync(batch);
                }
堆栈跟踪:

at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)\n  
at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)\n
--- End of stack trace from previous location where exception was thrown ---\n  
at System.Net.Security.SslStream.ThrowIfExceptional()\n 
at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)\n 
at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)\n   a
t System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)\n 
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__64_2(IAsyncResult iar)\n 
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)\n
--- End of stack trace from previous location where exception was thrown ---\n
at Microsoft.Azure.Amqp.TaskHelpers.EndAsyncResult(IAsyncResult asyncResult)\n 
at Microsoft.Azure.Amqp.StreamExtensions.EndAuthenticateAsClient(SslStream sslStream, IAsyncResult asyncResult)\n
at Microsoft.Azure.Amqp.Transport.TlsTransport.HandleOpenComplete(IAsyncResult result, Boolean syncComplete)\n
--- End of stack trace from previous location where exception was thrown ---\n 
at Microsoft.Azure.Amqp.ExceptionDispatcher.Throw(Exception exception)\n
at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result)\n  
at Microsoft.Azure.Amqp.AmqpObject.OpenAsyncResult.End(IAsyncResult result)\n  
at Microsoft.Azure.Amqp.AmqpObject.EndOpen(IAsyncResult result)\n  
at Microsoft.Azure.Amqp.Transport.TlsTransportInitiator.HandleTransportOpened(IAsyncResult result)\n
at Microsoft.Azure.Amqp.Transport.TlsTransportInitiator.OnTransportOpened(IAsyncResult result)\n
--- End of stack trace from previous location where exception was thrown    ---\n 
at Azure.Messaging.EventHubs.Amqp.AmqpConnectionScope.CreateAndOpenConnectionAsync(Version amqpVersion, Uri serviceEndpoint, EventHubsTransportType transportType, IWebProxy proxy, String scopeIdentifier, TimeSpan timeout)\n
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)\n 
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)\n 
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)\n  
at Azure.Messaging.EventHubs.Amqp.AmqpConnectionScope.OpenProducerLinkAsync(String partitionId, TimeSpan timeout, CancellationToken cancellationToken)\n   at Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateLinkAndEnsureProducerStateAsync(String partitionId, TimeSpan timeout, CancellationToken cancellationToken)\n   at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)\n
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)\n 
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)\n  
at Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateBatchAsync(CreateBatchOptions options, CancellationToken cancellationToken)\n  
at Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateBatchAsync(CreateBatchOptions options, CancellationToken cancellationToken)\n  
at Azure.Messaging.EventHubs.Producer.EventHubProducerClient.CreateBatchAsync(CreateBatchOptions options, CancellationToken cancellationToken)\n   at Azure.Messaging.EventHubs.Producer.EventHubProducerClient.CreateBatchAsync(CancellationToken cancellationToken)\n",
位于System.Net.Security.SslStream.StartReadFrame(字节[]缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest)\n
位于System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)\n
---来自引发异常的上一个位置的堆栈结束跟踪---\n
位于System.Net.Security.SslStream.ThrowifeException()\n
位于System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult-lazyResult)\n
位于System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult结果)\n a
t System.Net.Security.SslStream.endAuthenticateTasClient(IAsyncResult asyncResult)\n
在System.Net.Security.SslStream.c.b\u 64\u 2(IAsyncResult iar)上\n
在System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar,Func`2 endFunction,Action`1 endAction,Task`1 promise,Boolean requiresSynchronization)\n
---来自引发异常的上一个位置的堆栈结束跟踪---\n
位于Microsoft.Azure.Amqp.TaskHelpers.EndAsyncResult(IAsyncResult asyncResult)\n
位于Microsoft.Azure.Amqp.StreamExtensions.EndAuthenticateTaseClient(SslStream SslStream,IAsyncResult asyncResult)\n
位于Microsoft.Azure.Amqp.Transport.TlsTransport.HandleOpenComplete(IAsyncResult结果,布尔同步完成)\n
---来自引发异常的上一个位置的堆栈结束跟踪---\n
位于Microsoft.Azure.Amqp.ExceptionDispatcher.Throw(异常)\n
在Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult结果)\n
位于Microsoft.Azure.Amqp.AMQPOJECT.OpenAsyncResult.End(IAsyncResult结果)\n
位于Microsoft.Azure.Amqp.AMQPOJECT.ONPEEN(IAsyncResult结果)\n
在Microsoft.Azure.Amqp.Transport.TlsTransportInitiator.HandletTransportOpen(IAsyncResult结果)\n
在Microsoft.Azure.Amqp.Transport.TlsTransportInitiator.OnTransportOpen(IAsyncResult结果)\n
---来自引发异常的上一个位置的堆栈结束跟踪---\n
在Azure.Messaging.EventHubs.Amqp.AmqpConnectionScope.CreateAndOpenConnectionAsync(版本amqpVersion,Uri serviceEndpoint,EventHubsTransportType transportType,IWebProxy代理,字符串scopeIdentifier,时间跨度超时)\n
位于Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAync(TimeSpan超时)\n
位于Microsoft.Azure.Amqp.Singleton`1.GetorCreateAync(TimeSpan超时)\n
位于Microsoft.Azure.Amqp.Singleton`1.GetorCreateAync(TimeSpan超时)\n
位于Azure.Messaging.EventHubs.Amqp.AmqpConnectionScope.OpenProducerLinkAsync(字符串分区ID、时间跨度超时、取消令牌取消令牌)\n位于Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateLinkAndensureStateAsync(字符串分区ID、时间跨度超时、取消令牌取消令牌)\n位于Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAync(时间跨度超时)\n
位于Microsoft.Azure.Amqp.Singleton`1.GetorCreateAync(TimeSpan超时)\n
位于Microsoft.Azure.Amqp.Singleton`1.GetorCreateAync(TimeSpan超时)\n
位于Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateBatchAsync(CreateBatchOptions选项,CancellationToken CancellationToken)\n
位于Azure.Messaging.EventHubs.Amqp.AmqpProducer.CreateBatchAsync(CreateBatchOptions选项,CancellationToken CancellationToken)\n
位于Azure.Messaging.EventHubs.Producer.EventHubProducerClient.CreateBatchAsync(CreateBatchOptions选项,CancellationToken CancellationToken)\n位于Azure.Messaging.EventHubProducerClient.CreateBatchAsync(CancellationToken CancellationToken)\n“,
其他数据: 已尝试按照类似主题中的建议添加此内容,但没有帮助


ServicePointManager.SecurityProtocol |=SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

有一些未提及的重要信息-通过Kubernetes在docker中部署了服务


此错误与我们公司的内部防火墙设置有关。

这看起来肯定是服务拒绝了连接,但我不确定原因。您介意分享生产者是如何创建的吗?我想了解传输是为TCP还是为WebSocket设置的。producerClient=new EventHubProducerClient(连接字符串),因此我希望使用默认tcp连接谢谢。您的假设是正确的;tcp被用作默认传输。不幸的是,由于这似乎是在服务中发生的,因此我无法从客户端的角度提供太多的见解。我将与Event Hubs服务团队跟进,并要求他们提供帮助。您有吗是否有可能启用了IP筛选器或VNET?azure portal帐户中没有IP筛选器或VNET配置,其配置接近默认值。以前我对公司防火墙有问题,但在这一阶段我得到了System.Net.Sockets.SocketException(现在已修复)。