Hello
I've got a problem when my worker role is connecting to a service bus relay. It has worked for atleast two years but it suddenly stopped working 4 days ago. Do anyone know if MS changed something that could cause this or any other tips on how to fix the problem.
We have services running on our customers servers and they create the relays on the service bus and this works fine. Creates when I start my service and deletes when i stop the service. But when my worker role wants to connect to the relay i get a timeout after a short time and I have no clue on what to do now.
The code for opening the channel:
public bool OpenChannel() { //start channel if it is null //_channel.Abort(); if (_channel == null) { try { ServiceBusCreateChannel(CustomerLicense); if (_channel == null) return false; _channel.Open(new TimeSpan(1, 0, 2, 30)); } catch (CommunicationException ex) { //we dont log that the channel is down. Otherwise we just flood the log. //the heartbeat takes care of showing if the channel is down. //cls.Logger.LogMessage(ex, "Service channel down for customer" + _customerId); if (_channel != null) _channel.Abort(); _channel = null; return false; } catch (Exception ex) { //we log thisone because its some other error than the channel is down. //Logger.LogMessage(ex, "Service channel error for customerLicense" + CustomerLicense); if (_channel != null) _channel.Abort(); _channel = null; return false; } } //just MAKING BLOODY sure that the thing is opened and is not in some sort of limbo. //we do not try to open it at once. We let the callee sleep and try again and it will open if (_channel.State != CommunicationState.Opened) { if (_channel != null) _channel.Abort(); _channel = null; return false; } return _channel.State == CommunicationState.Opened; } private void ServiceBusCreateChannel(Guid serviceBusId) { //todo: get these settings to the database. //each setting is unique per customer. Just Set a new endpointaddress per customer string serviceNamespace = "sb://infowell.servicebus.windows.net/" + serviceBusId.ToString().Replace("-", "").ToLower(); string issuerName = "Owner"; string issueSecret = "hidden"; var sharedSecretServiceBusCredential = new TransportClientEndpointBehavior { TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issueSecret) }; var channelFactory = new ChannelFactory<IMessageChannel>(); channelFactory.Endpoint.Address = new EndpointAddress(serviceNamespace); var tcpBinding = new NetTcpRelayBinding { ConnectionMode = TcpRelayConnectionMode.Hybrid, MaxReceivedMessageSize = 20000000, MaxBufferSize = 20000000, MaxBufferPoolSize = 20000000, ReaderQuotas = new XmlDictionaryReaderQuotas { MaxDepth = 32, MaxArrayLength = 20000000, MaxStringContentLength = 20000000 }, }; tcpBinding.Security.Mode = EndToEndSecurityMode.None; channelFactory.Endpoint.Binding = tcpBinding; channelFactory.Endpoint.Contract.ContractType = typeof(IMessageChannel); channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential); _channel = channelFactory.CreateChannel(); _channel.OperationTimeout = new TimeSpan(1, 0, 2, 10); }