通过http后台代理发布到Azure服务总线
我使用Azure ServiceBus API发布到服务总线上。sb协议在防火墙后不起作用。因此,我将ServiceBusEnvironment.SystemConnectivity.Mode设置为ConnectivityMode.Http。只要我能直接连接到互联网,这一切都能正常工作。即使配置了http代理,这在我的办公室也不起作用。ServiceBus API是否存在问题?谢谢你在这方面的帮助 下面是我使用的一段代码通过http后台代理发布到Azure服务总线,azure,servicebus,Azure,Servicebus,我使用Azure ServiceBus API发布到服务总线上。sb协议在防火墙后不起作用。因此,我将ServiceBusEnvironment.SystemConnectivity.Mode设置为ConnectivityMode.Http。只要我能直接连接到互联网,这一切都能正常工作。即使配置了http代理,这在我的办公室也不起作用。ServiceBus API是否存在问题?谢谢你在这方面的帮助 下面是我使用的一段代码 public static void Initialize()
public static void Initialize()
{
// Using Http to be friendly with outbound firewalls
ServiceBusEnvironment.SystemConnectivity.Mode =
ConnectivityMode.Http;
//InitializeQueue();
}
// The name of your queue
public const string QueueName = "ordersqueue";
public static NamespaceManager CreateNamespaceManager()
{
// Create the namespace manager which gives you access to
// management operations
var uri = ServiceBusEnvironment.CreateServiceUri(
"sb", Namespace, String.Empty);
var tP = TokenProvider.CreateSharedSecretTokenProvider(
IssuerName, IssuerKey);
return new NamespaceManager(uri, tP);
}
private static void InitializeQueue()
{
// Create the namespace manager which gives you access to
// management operations
var namespaceManager = CreateNamespaceManager();
// Create the queue if it does not exist already
if (!namespaceManager.QueueExists(QueueName))
{
namespaceManager.CreateQueue(QueueName);
}
// Get a client to the queue
var messagingFactory = MessagingFactory.Create(
namespaceManager.Address,
namespaceManager.Settings.TokenProvider);
OrdersQueueClient = messagingFactory.CreateQueueClient(
QueueName);
}
下面是我得到的堆栈跟踪。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
徖
Microsoft.ServiceBus.Messaging.MessagingCommunicationException was unhandled
Message=Unable to connect to ServiceBus using HTTP connectivity mode
Source=Microsoft.ServiceBus
IsTransient=true
StackTrace:
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage message)
at Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage message)
at AzureServiceBusPublisher.QueueConnector.send(String arg) in C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\QueueConnector.cs:line 72
at AzureServiceBusPublisher.Program.sendMessagesToQueue() in C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\Program.cs:line 23
at AzureServiceBusPublisher.Program.Main(String[] args) in C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ServiceModel.CommunicationException
Message=Unable to connect to ServiceBus using HTTP connectivity mode
Source=Microsoft.ServiceBus
StackTrace:
Server stack trace:
at Microsoft.ServiceBus.WebStream..ctor(Uri factoryEndpointUri, String webSocketRole)
at Microsoft.ServiceBus.WebSocketConnection..ctor(Uri factoryEndpointUri, String webSocketRole, Int32 asyncReadBufferSize)
at Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
at Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.BeginConnect(Uri uri, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.BufferedConnectionInitiator.BeginConnect(Uri uri, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult.OpenUsingNewConnection()
at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult.Begin()
at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult..ctor(ConnectionPoolHelper parent, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.BeginEstablishConnection(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OpenAsyncResult..ctor(ClientFramingDuplexSessionChannel duplexChannel, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnBeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.LayeredChannel`1.OnBeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.OnBeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()
at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.CommunicationObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Messaging.Channels.SharedChannel`1.GetInstanceAsyncResult.<GetAsyncSteps>b__3(GetInstanceAsyncResult thisPtr, TimeSpan t, AsyncCallback c, Object s)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()
Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Channels.SharedChannel`1.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__f(RequestAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
Exception rethrown at [1]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<GetAsyncSteps>b__44(TIteratorAsyncResult thisPtr, IAsyncResult a)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
Exception rethrown at [2]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
InnerException: System.ServiceModel.CommunicationException
Message=Unable to connect downstream
Source=Microsoft.ServiceBus
StackTrace:
at Microsoft.ServiceBus.WebStream.CreateDownStreamRequest(Uri endpointLocation)
at Microsoft.ServiceBus.WebStream.StartSession(Uri readEndpoint, Uri writeEndpoint)
at Microsoft.ServiceBus.WebStream..ctor(Uri factoryEndpointUri, String webSocketRole)
InnerException: System.Net.WebException
Message=The remote server returned an error: (403) Forbidden.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.ServiceBus.WebStream.CreateDownStreamRequest(Uri endpointLocation)
InnerException:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException未处理
消息=无法使用HTTP连接模式连接到ServiceBus
Source=Microsoft.ServiceBus
IsTransient=true
堆栈跟踪:
位于Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult结果)
位于Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult结果)
位于Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext TrackingContext,IEnumerable`1消息,TimeSpan超时)
在Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext TrackingContext,IEnumerable`1消息,TimeSpan超时)
位于Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage消息)
位于Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage消息)
在C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\QueueConnector.send中的AzureServiceBusPublisher.QueueConnector.send(字符串arg)处:第72行
位于C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\Program.cs中的AzureServiceBusPublisher.Program.sendMessagesToQueue():第23行
位于C:\Users\prasanh\Documents\Visual Studio 2010\Projects\AzureServiceBusPublisher\AzureServiceBusPublisher\Program.cs中的AzureServiceBusPublisher.Program.Main(字符串[]args):第13行
位于System.AppDomain.\u nExecuteAssembly(RuntimeAssembly程序集,字符串[]args)
位于System.AppDomain.ExecuteAssembly(字符串汇编文件、证据汇编安全性、字符串[]args)
在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()上
位于System.Threading.ThreadHelper.ThreadStart\u上下文(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态)
位于System.Threading.ThreadHelper.ThreadStart()处
InnerException:System.ServiceModel.CommunicationException
消息=无法使用HTTP连接模式连接到ServiceBus
Source=Microsoft.ServiceBus
堆栈跟踪:
服务器堆栈跟踪:
在Microsoft.ServiceBus.WebStream..ctor(Uri factoryEndpointUri,字符串webSocketRole)
位于Microsoft.ServiceBus.WebSocketConnection..ctor(Uri factoryEndpointUri,字符串webSocketRole,Int32 asyncReadBufferSize)
位于Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.Connect(Uri,TimeSpan超时)
位于Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.BeginConnect(Uri、TimeSpan超时、异步回调、对象状态)
位于Microsoft.ServiceBus.Channels.BufferedConnectionInitiator.BeginConnect(Uri、TimeSpan超时、异步回调、对象状态)
在Microsoft.ServiceBus.Channel.ConnectionPoolHelper.EstablishConnectionAsyncResult.OpenUsingNewConnection()中
在Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult.Begin()中
位于Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult..ctor(ConnectionPoolHelper父级、TimeSpan超时、异步回调、对象状态)
位于Microsoft.ServiceBus.Channels.ConnectionPoolHelper.BeginEstablishConnection(TimeSpan超时、异步回调、对象状态)
在Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OpenAsyncResult..ctor(ClientFramingDuplexSessionChannel duplexChannel,TimeSpan超时,异步回调,对象状态)
在Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnBeginOpen(时间跨度超时、异步回调、对象状态)
在Microsoft.ServiceBus.Channel.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject CommunicationObject,TimeSpan超时,异步回调,对象状态)
在Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(TimeSpan超时、异步回调、对象状态)
在Microsoft.ServiceBus.Channels.LayeredChannel`1.OnBeginOpen(TimeSpan超时、异步回调、对象状态)
在Microsoft.ServiceBus.Channel.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject CommunicationObject,TimeSpan超时,异步回调,对象状态)
在Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(TimeSpan超时、异步回调、对象状态)
位于Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.OnBeginOpen(时间跨度超时、异步回调、对象状态)
在System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()中
位于System.ServiceModel.Channel.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject CommunicationObject,TimeSpan超时,异步回调,对象状态)
位于System.ServiceModel.Channels.CommunicationObject.BeginOpen(TimeSpan超时、异步回调、对象状态)
在Microsoft.ServiceBus.Messaging.Channels.SharedChannel`1.GetInstanceAsyncResult.b_uu3(GetInstanceAsyncResult this