问题
I am building a POC for Azure Service Bus Topics using the code given on this blog post: http://blogs.msdn.com/b/tomholl/archive/2011/10/09/using-service-bus-topics-and-subscriptions-with-wcf.aspx However, I am getting following error.
System.TimeoutException: The request has timed out after 00:00:00 milliseconds. The successful completion of the request cannot be determined. Additional queries should be made to determine whether or not the operation has succeeded.
I have done everything as per the Link. Here is my Code, I receive error on this line: ((IChannel)clientChannerl).Open();
var accountEventLog = new AccountEventLog()
{
AccountId = 123,
EventType = "BE",
Date = DateTime.Now
};
ChannelFactory<IAccountEventNotification> factory = null;
try
{
factory = new ChannelFactory<IAccountEventNotification>("Subscribers");
var clientChannerl = factory.CreateChannel();
((IChannel)clientChannerl).Open();
using (new OperationContextScope((IContextChannel)clientChannerl))
{
var bmp = new BrokeredMessageProperty();
bmp.Properties["AccountId"] = accountEventLog.AccountId;
bmp.Properties["EventType"] = accountEventLog.EventType;
bmp.Properties["Date"] = accountEventLog.Date;
OperationContext.Current.OutgoingMessageProperties.Add(BrokeredMessageProperty.Name, bmp);
clientChannerl.onEventOccurred(accountEventLog);
}
((IChannel)clientChannerl).Close();
factory.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Here is my config settings
<behaviors>
<endpointBehaviors>
<behavior name="securityBehavior">
<transportClientEndpointBehavior>
<tokenProvider>
<sharedSecret issuerName="RootManageSharedAccessKey" issuerSecret="Shared Key Here" />
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netMessagingBinding>
<binding name="messagingBinding" sendTimeout="00:03:00" receiveTimeout="00:03:00"
openTimeout="00:03:00" closeTimeout="00:03:00" sessionIdleTimeout="00:01:00"
prefetchCount="-1">
<transportSettings batchFlushInterval="00:00:01" />
</binding>
</netMessagingBinding>
</bindings>
<client>
<endpoint name="Subscribers"
address="sb://Namespace/topicname"
binding="netMessagingBinding"
bindingConfiguration="messagingBinding"
contract="My Contract"
behaviorConfiguration="securityBehavior" />
</client>
Any help will be highly appreciated
回答1:
I am able to resolve the issue. However, I am going to describe what I learned in this whole exercise.
- The token provider added in the behavior is used for Service Bus Authentication with ACS (Active Directory Service)
- Namespaces created using Azure Portal don't create an ACS endpoint/ACS authentication by default. When you create a namespace it only creates SAS (Shared Access Signature) by default.
- To Authenticate your wcf call with SAS use this Token provider: <sharedAccessSignature keyName="RootManageSharedAccessKey" key="key" />
In case you want to use ACS authentication then create namespace using Azure Power Shell. Following is the PS command to create Namespace with ACS Authentication enabled:
New-AzureSBNamespace "Namespace" "East US" -CreateACSNamespace $true -NamespaceType Messaging
So to resolve my issue I used the Point 3 described above and it started working.
回答2:
Another thing to look out for, is has someone accidentally left the proxy enabled in your App.config or Web.config? This will produce a similar exception when sending.
Look for something like the following:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>
来源:https://stackoverflow.com/questions/30224200/azure-service-bus-topic-timeout-exception