title: Microsoft.ServiceBus.InvalidRequestException: The connection was failed. Cache refresh timed out
body: <p>Microsoft.ServiceBus.InvalidRequestException: The connection was failed. Cache refresh timed out. Server stack trace: at Microsoft.ServiceBus.RelayedSocketInitiator.Connect(Uri uri, TimeSpan timeout) at Microsoft.ServiceBus.ConnectivityModeConnectionInitiator.Connect(Uri uri, TimeSpan timeout) at Microsoft.ServiceBus.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout) at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type) at System.ServiceModel.ICommunicationObject.Open()</p>
  
  <p>when opening a connection with a NetTcpRelayBinding</p>
  
  <pre><code>try
  {
     NetTcpRelayBinding netTcpRelay = new NetTcpRelayBinding();
     if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxConnections &gt; 0)
     {
       netTcpRelay.MaxConnections = ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxConnections;
      }
      netTcpRelay.MaxReceivedMessageSize = ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientMaxReceivedMessageSize;
      if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientSendTimeout &gt; 0)
      {
       netTcpRelay.SendTimeout = new TimeSpan(0, 0, ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientSendTimeout);
       }
  
     if (ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientReceiveTimeout &gt; 0)
      {
        netTcpRelay.ReceiveTimeout = new TimeSpan(0, 0, ApplicationServer.Common.Utilities.ServicesConfigurationManager.ClientReceiveTimeout);
        }
  
      channelFactory = new ChannelFactory&lt;TServiceChannel&gt;(
                                 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);
                  }
  </code></pre>