Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:06:57+00:00 2026-05-29T08:06:57+00:00

I’m hosting my REST services by an ASP.NET application on Windows Azure. It’s working

  • 0

I’m hosting my REST services by an ASP.NET application on Windows Azure. It’s working perfect, but I needed an Inter-Role communication service a few days ago, I built my service but I have problems with hosting it.

This Code in my Global.asax works great in my local Azure Development Server but It did not work in Azure Cloud.

What is the best way to host them correctly?

Global.asax:

public class Global : HttpApplication
{
    void Application_Start(object sender, EventArgs e)
    {
        StartNotificationServiceHost();
        RegisterRoutes();
    }

    public ServiceHost ServiceHost { get; private set; }
    private void RegisterRoutes()
    {
        var hostfactory = new WebServiceHostFactory();
        RouteTable.Routes.Add(new ServiceRoute("REST/Companies",hostfactory, typeof(Companies)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Public", hostfactory, typeof(Public)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Users", hostfactory, typeof(Users)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Contacts", hostfactory, typeof(Contacts)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Projects", hostfactory, typeof(Projects)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Instances", hostfactory, typeof(Instances)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Activity", hostfactory, typeof(Activity)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Search", hostfactory, typeof(Search)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Tasks", hostfactory, typeof(Tasks)));
        RouteTable.Routes.Add(new ServiceRoute("REST/Documents", hostfactory, typeof(Documents)));
    }
    private void StartNotificationServiceHost()
    {
        Trace.WriteLine("Starting Service Host", "Information");
        NotificationServiceHost serviceHostBase = new NotificationServiceHost();
        serviceHostBase.RecycleNotificationRecieved += new RecycleNotificationRecievedEventHandler(ServiceHost_RecycleNotificationRecieved);
        serviceHostBase.CheckInstanceStatusRecieved += new CheckInstanceStatusRecievedEventHandler(serviceHostBase_CheckInstanceStatusRecieved);
        ServiceHost = new ServiceHost(serviceHostBase);
        this.ServiceHost.Faulted += (sender, e) =>
        {
            Trace.TraceError("Service Host fault occured");
            this.ServiceHost.Abort();
            Thread.Sleep(500);
            this.StartNotificationServiceHost();

        };
        NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
        RoleInstanceEndpoint notificationServiceHostEndPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["NotificationServiceEndPoint"];
        this.ServiceHost.AddServiceEndpoint(
            typeof(INotifyService),
            binding,
            String.Format("net.tcp://{0}/NotifyService", notificationServiceHostEndPoint.IPEndpoint)
            );
        try
        {
            this.ServiceHost.Open();
            Trace.TraceInformation("Service Host Opened");
        }
        catch (TimeoutException timeoutException)
        {
            Trace.TraceError("Service Host open failure, Time Out: " + timeoutException.Message);
        }
        catch (CommunicationException communicationException)
        {
            Trace.TraceError("Service Host open failure, Communication Error: " + communicationException.Message);
        }
        Trace.WriteLine("Service Host Started", "Information");
    }
        InstanceItem serviceHostBase_CheckInstanceStatusRecieved(object sender, int e)
        {
...
        }
        void ServiceHost_RecycleNotificationRecieved(object sender, NotificationMessage e)
        {
...

        }
}

Web.config/ServiceModel section:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- This behavior enables API Key Verification -->
          <serviceAuthorization serviceAuthorizationManagerType="OfisimCRM.Webservice.APIKeyAuthorization, OfisimCRM.Webservice" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
          <serviceValidator />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add name="serviceValidator" type="OfisimCRM.Webservice.WebHttpWithValidationBehaviorExtension, OfisimCRM.Webservice, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint crossDomainScriptAccessEnabled="true" faultExceptionEnabled="true" hostNameComparisonMode="WeakWildcard" name="" defaultOutgoingResponseFormat="Json" helpEnabled="true" automaticFormatSelectionEnabled="true" maxBufferSize="65536" maxReceivedMessageSize="104857600" transferMode="Streamed" />
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

ServiceDefinition/WebRole:

 <WebRole name="OfisimCRM.WebClient" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
      <InternalEndpoint name="NotificationServiceEndPoint" protocol="tcp" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
      <Import moduleName="RemoteAccess" />
    </Imports>
    <ConfigurationSettings>
    </ConfigurationSettings>
  </WebRole>

Error:

The server encountered an error processing the request. The exception message is 'Could not connect to net.tcp://x.x.x.29:8000/NotifyService. The connection attempt lasted for a time span of 00:00:21.0918600. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond x.x.x.29:8000. '. See server logs for more details.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:06:58+00:00Added an answer on May 29, 2026 at 8:06 am

    Role instances access has been restricted by the Firewall. Usually, the instance accepts connections only from the load balancer. You add setting to service definition file (*.csdef) as follows, and it is necessary to accept connection.

    <?xml version="1.0" encoding="utf-8" ?>
      <ServiceDefinition name="RoleCommunication" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> 
    : 
      <NetworkTrafficRules> 
        <OnlyAllowTrafficTo> 
          <Destinations> 
            <RoleEndpoint endpointName="YourEndPointName" roleName="YourRole" /> 
          <Destinations> 
          <WhenSource matches="AnyRole"> 
            <FromRole roleName="YourRole" /> 
          </WhenSource> 
        </OnlyAllowTrafficTo> 
      </NetworkTrafficRules> 
    </ServiceDefinition >
    

    Alternatively, you can add rule the connection expresily using netsh command in Startup Task.

    ex)
    netsh advfirewall firewall add rule name=”YourEndPoint” dir=in action=allow localport=80 protocol=tcp

    ====

    Is ‘InternalEndpoint’ a dynamic port? If possible, Could you set a fixed port in .csdef and startup task.

    ex)

    <InternalEndpoint name="NotificationServiceEndPoint" protocol="tcp" port="8000"/>
    

    and

    netsh advfirewall firewall add rule name="NotificationServiceEndPoint" dir=in action=allow localport=8000 protocol=tcp
    

    ====

    Or, Environment Variable is available as follows:

       <Endpoints>
          <InputEndpoint name="Endpoint1" protocol="http" port="80" />
          <InternalEndpoint name="NotificationServiceEndPoint" protocol="tcp" />
        </Endpoints>
    
          <Startup>
              <Task commandLine="configfirewall.cmd" executionContext="elevated" taskType="simple">
                  <Environment>
                      <Variable name="NotificationServiceEndPointPort" value="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='NotificationServiceEndPoint']/@port" />
                  </Environment>
              </Task>
          </Startup>
    

    and You use environment variable in startup tasks

    netsh advfirewall firewall add rule name="ServiceEndPoint" dir=in action=allow localport=%NotificationServiceEndPointPort% protocol=tcp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.