none
Hosting a WCF Web Service on the Service Bus behind the HTTP proxy

    Question

  • Hello!

    I have a weird situation here. may be someone could help me out...

    What do I have:

    Here is a code that I am using to host a Service on Azure Service bus...

    ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;            
    
    WebProxy proxy = new WebProxy("proxy.myInternalHostName:8080", true);
    
    proxy.UseDefaultCredentials = true;
    
    HttpWebRequest.DefaultWebProxy = proxy;
    
    ServiceHost sh = new ServiceHost(typeof(ProblemSolver));
    
                var binding = new WebHttpRelayBinding();
    
                binding.UseDefaultWebProxy = true;
    
                
    
                sh.AddServiceEndpoint(
    
                   typeof(IProblemSolver), binding,
    
                   ServiceBusEnvironment.CreateServiceUri("sb", "MYNAMESPACENAME", "solver"))
    
                    .Behaviors.Add(new TransportClientEndpointBehavior
    
                    {
    
                        TokenProvider = TokenProvider.CreateSharedSecretTokenProvider("owner", "MYSHAREDKEY")
    
                    });
    
    
    
                sh.Open();
    
                Console.WriteLine("Press ENTER to close");
    
                Console.ReadLine();
    
                sh.Close();
    


    The problem is that it hangs forever on the sh.Open(); call (i did wait for 10 mites or so). and its definetly related to the proxy settings because if i remove the proxy settings code it starts failing with the Proxy Auth. errors.

    Also this code works without proxy server on a different PC(that has a direct Internet Access).

    Any ideas?

     

    PS if I set the proxy

    WebProxy proxy = new WebProxy("proxy.myInternalHostName:8080", true);
    
    proxy.UseDefaultCredentials = true;
    
    HttpWebRequest.DefaultWebProxy = proxy;
    

    and then call the following code everthing works.

    var httpRequest = WebRequest.Create("http://google.com");
    
                using (var webResponse = httpRequest.GetResponse())//this is the line taking ages.
                {
                    using (var sr = new StreamReader(webResponse.GetResponseStream()))
                        Trace.WriteLine(sr.ReadToEnd());
                }
    
    :(

    Wednesday, January 25, 2012 8:53 AM

All replies

  • Hi,

    It is not recommended to hard code proxy settings except for debugging issues. Proxy server can change. If you hard code a proxy, once the proxy server changes, you have to modify the code recompile, and redeploy the application.

    It is highly recommended to use an OS wide proxy configuration. For example, if you use ISA proxy server, you can install ISA client on your machine and configure it properly. Then all applications will work without any specific proxy settings. You can contact your IT for information on how to configure your proxy.

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Thursday, January 26, 2012 3:31 AM
  • Hi,

    Yes you are absolutly right about the hardcoding of the proxy settings.

    This is only for debug.

    what I undestand from your answer that the scenario that I am trying to implement is not supported.(I don't have a ISA server here... probably this is a Squid server.) And it is imposible to set up a transparent proxy here.

    Am I right?

     

    thanks,

    Vlad.

    Thursday, January 26, 2012 7:13 AM
  • Hi,

    This is supported, providing you have configured the proxy correctly. I don't know how to configure your proxy in your environment. You probably need to contact your IT for help. In general, to configure a proxy specific to a particular .NET application, you can use the defaultProxy tag in app.config: http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx.

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Thursday, January 26, 2012 7:26 AM
  • Hi,

    thanks for info.

    I have been aware of this configuration tag and I tried it already with no luck, it hangs on sh.Open();

    So it looks like there is no difference between my code and app.config changes.

     

    thanks,

    Vlad.

    Thursday, January 26, 2012 8:27 AM
  • This is an issue in service bus. We will fix it in the future.
    Friday, February 03, 2012 9:04 AM
  • When will this issue be fixed?  It is really annoying and I cannot find a solution.
    Thursday, June 07, 2012 2:42 PM
  • Looks like a problem has not been fixed in in Azure SDK 1.7... So sad.

    Any update/roadmap or anything on that?...

    Agree with previous post. it is really annoying...

    Monday, July 09, 2012 9:00 AM