Microsoft.ServiceBus.InvalidRequestException:连接失败。缓存刷新超时

时间:2018-03-06 15:31:14

标签: c# azure wcf-binding azure-servicebusrelay

Microsoft.ServiceBus.InvalidRequestException:连接失败。缓存刷新超时。服务器堆栈跟踪:位于Microsoft.ServiceBus.ConnectivityModeConnectionInitiator.Connect(Uri uri,TimeSpan超时)的Microsoft.ServiceBus.RelayedSocketInitiator.Connect(Uri uri,TimeSpan timeout),位于Microsoft.ServiceBus.Channels.BufferedConnectionInitiator.Connect(Uri uri,TimeSpan timeout) )位于System.ServiceModel.Channels的System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan超时)的Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan超时)的Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan超时)。 System.ServiceModel.Channels.OnOpen(TimeSpan timeout)在System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)上的CommunicationObject.Open(TimeSpan timeout)在[0]处重新抛出异常:在System.Runtime.Remoting.Proxies .RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)at at System.ServiceModel.ICommunicationObject.Open()

打开与NetTcpRelayBinding的连接

try
{
   NetTcpRelayBinding netTcpRelay = new NetTcpRelayBinding();
   if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxConnections > 0)
   {
     netTcpRelay.MaxConnections = ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxConnections;
    }
    netTcpRelay.MaxReceivedMessageSize = ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxReceivedMessageSize;
    if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientSendTimeout > 0)
    {
     netTcpRelay.SendTimeout = new TimeSpan(0, 0, ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientSendTimeout);
     }

   if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientReceiveTimeout > 0)
    {
      netTcpRelay.ReceiveTimeout = new TimeSpan(0, 0, ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientReceiveTimeout);
      }

    channelFactory = new ChannelFactory<TServiceChannel>(
                               netTcpRelay,
                               new EndpointAddress(serviceBusUri));

                    // Set the signature token
                    policyName = ...
                    accessKey = ...
                    channelFactory.Endpoint.Behaviors.Add(new TransportClientEndpointBehavior { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(policyName, accessKey) });
                }
                catch (Exception exc)
                {
                    throw new ServiceBusRelayException("\nServiceBusRelayProxyHelper.Initialize (sb://): An error ocurred with ServiceBusUri='" + serviceBusUri + "' - PolicyName='"+ policyName +"'.\nException Message: " + exc.Message, exc);
                }

1 个答案:

答案 0 :(得分:0)

从今天开始,我有同样的问题。这对您的代码来说不是问题,我必须使用MSFT支持来解决问题。他们不得不将我的服务总线命名空间移动到另一个节点,然后解决了这个问题。我建议使用Azure支持打开支持服务单。