发布到Azure的服务总线通过HTTP代理背后 [英] Publish to Azure Service Bus over http behind proxy

查看:185
本文介绍了发布到Azure的服务总线通过HTTP代理背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Azure ServiceBus API发布到服务总线。在SB协议没有在防火墙后面工作。因此,我设置为ServiceBusEnvironment.SystemConnectivity.Mode ConnectivityMode.Http。这是工作,只要我是直接连接到互联网。这难道不在我的办公室工作,即使配置HTTP代理服务器之后。是否存在与ServiceBus API的一个问题?鸭美元,该p $ pciate你的帮助。

下面是一块code,我用....

 公共静态无效初始化()
    {
        //使用HTTP与出站防火墙友好
        ServiceBusEnvironment.SystemConnectivity.Mode =
            ConnectivityMode.Http;        // InitializeQueue();
    }
    //你的队列的名称
    公共常量字符串QUEUENAME =ordersqueue;    公共静态NamespaceManager CreateNamespaceManager()
    {
        //创建命名空间管理器,它允许您访问
        //管理操作
        VAR URI = ServiceBusEnvironment.CreateServiceUri(
            SB,命名空间的String.Empty);
        变种TP = TokenProvider.CreateSharedSecretTokenProvider(
            发行者名称,IssuerKey);
        返回新NamespaceManager(URI,TP);
    }    私有静态无效InitializeQueue()
    {
        //创建命名空间管理器,它允许您访问
        //管理操作
        变种namespaceManager = CreateNamespaceManager();        //创建队列如果不存在的话
        如果(!namespaceManager.QueueExists(QUEUENAME))
        {
            namespaceManager.CreateQueue(QUEUENAME);
        }        //获取客户端的队列
        VAR messagingFactory = MessagingFactory.Create(
            namespaceManager.Address,
            namespaceManager.Settings.TokenProvider);
        OrdersQueueClient = messagingFactory.CreateQueueClient(
            QUEUENAME);
    }

下面是堆栈跟踪我得到................................
.................................................. .............

  Microsoft.ServiceBus.Messaging.MessagingCommunicationException了未处理
  消息=无法使用HTTP连接模式连接到ServiceBus
  来源= Microsoft.ServiceBus
  IsTransient =真
  堆栈跟踪:
       在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult的结果)
       在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult的结果)
       在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext trackingContext,IEnumerable`1的消息,时间跨度超时)
       在Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext,IEnumerable`1的消息,时间跨度超时)
       在Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage消息)
       在Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage消息)
       在AzureServiceBusPublisher.QueueConnector.send(字符串ARG)在C:\\用户\\ prasanh \\文档\\ Visual Studio 2010的\\项目\\ AzureServiceBusPublisher \\ AzureServiceBusPublisher \\ QueueConnector.cs:行72
       在AzureServiceBusPublisher.Program.sendMessagesToQueue()在C:\\用户\\ prasanh \\文档\\ Visual Studio 2010的\\项目\\ AzureServiceBusPublisher \\ AzureServiceBusPublisher \\的Program.cs:行23
       在AzureServiceBusPublisher.Program.Main(字串[] args)在C:\\用户\\ prasanh \\文档\\ Visual Studio 2010的\\项目\\ AzureServiceBusPublisher \\ AzureServiceBusPublisher \\的Program.cs:行13
       在System.AppDomain._nExecuteAssembly(RuntimeAssembly组装,字串[] args)
       在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据assemblySecurity,字串[] args)
       在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
       在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
       来源= Microsoft.ServiceBus
       堆栈跟踪:
         服务器堆栈跟踪:
            在Microsoft.ServiceBus.WebStream..ctor(URI factoryEndpointUri,字符串webSocketRole)
            在Microsoft.ServiceBus.WebSocketConnection..ctor(URI factoryEndpointUri,字符串webSocketRole,的Int32 asyncReadBufferSize)
            在Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.Connect(URI URI,时间跨度超时)
            在Microsoft.ServiceBus.WebSocketOnewayConnectionInitiator.BeginConnect(URI URI,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.BufferedConnectionInitiator.BeginConnect(URI URI,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult.OpenUsingNewConnection()
            在Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult.Begin()
            在Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnectionAsyncResult..ctor(ConnectionPoolHelper父母,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.ConnectionPoolHelper.BeginEstablishConnection(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OpenAsyncResult..ctor(ClientFramingDuplexSessionChannel duplexChannel,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnBeginOpen(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject的CommunicationObject的,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.LayeredChannel`1.OnBeginOpen(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject的CommunicationObject的,时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Channels.CommunicationObject.BeginOpen(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.OnBeginOpen(TimeSpan超时,AsyncCallback的回调,对象状态)
            在System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()
            在System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject的CommunicationObject的,时间跨度超时,AsyncCallback的回调,对象状态)
            在System.ServiceModel.Channels.CommunicationObject.BeginOpen(时间跨度超时,AsyncCallback的回调,对象状态)
            在Microsoft.ServiceBus.Messaging.Channels.SharedChannel`1.GetInstanceAsyncResult.<GetAsyncSteps>b__3(GetInstanceAsyncResult thisPtr,时间跨度T,AsyncCallback的C,一个Object)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType状态)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()
         [0]时异常重新抛出:
            在Microsoft.ServiceBus.Common.AsyncResult.End [TAsyncResult](IAsyncResult的结果)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult的asyncResult)
            在Microsoft.ServiceBus.Messaging.Channels.SharedChannel`1.OnEndCreateInstance(IAsyncResult的asyncResult)
            在Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult的asyncResult)
            在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__f(RequestAsyncResult thisPtr,IAsyncResult的R)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType状态)
         在[1]异常重新抛出:
            在Microsoft.ServiceBus.Common.AsyncResult.End [TAsyncResult](IAsyncResult的结果)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult的asyncResult)
            在Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult结果)
            在Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<GetAsyncSteps>b__44(TIteratorAsyncResult thisPtr,IAsyncResult的一)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType状态)
         在[2]异常重新抛出:
            在Microsoft.ServiceBus.Common.AsyncResult.End [TAsyncResult](IAsyncResult的结果)
            在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult的asyncResult)
            在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult的结果)
       的InnerException:System.ServiceModel.CommunicationException
            消息=无法连接下游
            来源= Microsoft.ServiceBus
            堆栈跟踪:
                 在Microsoft.ServiceBus.WebStream.CreateDownStreamRequest(URI endpointLocation)
                 在Microsoft.ServiceBus.WebStream.StartSession(URI readEndpoint,乌里writeEndpoint)
                 在Microsoft.ServiceBus.WebStream..ctor(URI factoryEndpointUri,字符串webSocketRole)
            的InnerException信息:System.Net.WebException
                 消息=远程服务器返回错误:(403)禁止。
                 来源=系统
                 堆栈跟踪:
                      在System.Net.HttpWebRequest.GetResponse()
                      在Microsoft.ServiceBus.WebStream.CreateDownStreamRequest(URI endpointLocation)
                 的InnerException:


解决方案

微软本周发布了新的服务总线API。请参见下面的链接
http://msdn.microsoft.com/en-us/library /windowsazure/hh667331.aspx#New_SB
我在服务总线1.8测试了这个问题。还是同样的错误。任何人都可以请指导我微软是否已经修复了这个问题?

I used Azure ServiceBus API to publish onto Service Bus. The sb protocol does not work behind the firewall. Hence I set ServiceBusEnvironment.SystemConnectivity.Mode to ConnectivityMode.Http. This was working as long as I was directly connected to the internet. This wouldnt work in my office, even after configuring the http proxy. Is there an issue with the ServiceBus API? Appreciate your help on this.

Below is the piece of code that I used....

    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);
    }

Below is the stack trace I get................................ ...............................................................

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 has released new service bus API this week. See the links below http://msdn.microsoft.com/en-us/library/windowsazure/hh667331.aspx#New_SB I have tested this issue in service bus 1.8. Still the same error. can anyone please guide me whether microsoft has fixed this issue ?

这篇关于发布到Azure的服务总线通过HTTP代理背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆