2015-09-12 11 views
6

पर काम नहीं करता है मेरे पास दो वेब भूमिकाएं हैं और इनमें से एक सेवा परत चलाती है जिसमें नेट डब्ल्यूसीएफ सेवाओं से जुड़े 3 डब्ल्यूसीएफ सेवाएं शामिल हैं, प्रत्येक पोर्ट 808, 810 पर वेबसाइट के रूप में तैनात हैं, और 811.डब्ल्यूसीएफ सेवा के लिए आंतरिक अंतराल एज़ूर वेब भूमिका

अब मैं सेवा परत को केवल अपनी अन्य वेब भूमिका के लिए खोलना चाहता हूं।

इसलिए मैंने सेवाओं में से एक को आंतरिक बिंदु बनाने और मेरी अगली वेब भूमिका के लिए पहुंच देने की कोशिश की।

इस तरह

:

<ServiceDefinition name="MagnusAzureCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6"> <WebRole name="Core.Services" vmsize="Small"> <Runtime executionContext="elevated" /> <Startup> <Task commandLine="Startup/startup.cmd" executionContext="elevated" taskType="background" /> </Startup> <Sites> <Site name="Core" physicalDirectory="C:\CoreServices"> <Bindings> <Binding name="Endpoint1" endpointName="Endpoint1" /> </Bindings> </Site> <Site name="Store" physicalDirectory="C:\StoreServices"> <Bindings> <Binding name="Endpoint3" endpointName="Endpoint3" /> </Bindings> </Site> <Site name="Users" physicalDirectory="C:\UserServices"> <Bindings> <Binding name="Endpoint4" endpointName="Endpoint4" /> </Bindings> </Site> </Sites> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </ConfigurationSettings> <Endpoints> <InputEndpoint name="Endpoint1" protocol="http" port="8282" /> <InputEndpoint name="Endpoint3" protocol="http" port="81" /> <InputEndpoint name="Endpoint4" protocol="http" port="8181" /> <InputEndpoint name="Endpoint2" protocol="tcp" port="808" localPort="808" /> <InputEndpoint name="Endpoint5" protocol="tcp" port="810" localPort="810" /> <InternalEndpoint name="Endpoint6" protocol="tcp" port="811" /> </Endpoints> <Certificates> </Certificates> <Imports> <Import moduleName="RemoteAccess" /> <Import moduleName="RemoteForwarder" /> </Imports> </WebRole> <WebRole name="UIWeb" vmsize="Small"> <Runtime executionContext="elevated" /> <Startup> <Task commandLine="Startup/startup.cmd" executionContext="elevated" taskType="background" /> </Startup> <Sites> <Site name="Web"> <Bindings> <Binding name="Endpoint1" endpointName="Endpoint1" /> </Bindings> </Site> </Sites> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> </ConfigurationSettings> <Endpoints> <InputEndpoint name="Endpoint1" protocol="http" port="80" /> </Endpoints> <Imports> <Import moduleName="RemoteAccess" /> </Imports> </WebRole> <NetworkTrafficRules> <OnlyAllowTrafficTo> <Destinations> <RoleEndpoint endpointName="Endpoint6" roleName="Core.Services" /> </Destinations> <WhenSource matches="AnyRule"> <FromRole roleName="UIWeb"/> </WhenSource> </OnlyAllowTrafficTo> </NetworkTrafficRules> </ServiceDefinition>

लेकिन जब UserService प्रयास किया गया तो उसका समय लगता है।

'/' एप्लिकेशन में सर्वर त्रुटि।

के माध्यम से कनेक्ट करने के लिए net.tcp: //myservicename.cloudapp.net: 811/UserTypeService.svc 00:00:00 के बाद का समय समाप्त हो गया। कनेक्शन प्रयास 1 उपलब्ध पते() में 0 के लिए किए गए थे। अपने चैनल की रिमोट एड्रेस जांचें और सत्यापित करें कि इस एंडपॉइंट के लिए DNS रिकॉर्ड्स मान्य आईपी पते से मेल खाते हैं। इस ऑपरेशन को आवंटित समय लंबा टाइमआउट का हिस्सा हो सकता है।

मैंने <WhenSource ...> के बजाय <AllowAllTraffic/> सेट करने का भी प्रयास किया है, लेकिन इसका कोई प्रभाव नहीं है।

दूसरा प्रयास: कुछ प्रतिक्रिया के बाद मैं एक FixedPort और 811 के लिए PortRange और भूमिका port="*" को सुनने के स्थापित करने के लिए कुछ रूपांतरों कोशिश की है।

<InternalEndpoint name="Endpoint6" protocol="tcp" port="*" > 
     <FixedPortRange min="811" max="811"></FixedPortRange> 
    </InternalEndpoint> 

मैंने नेटवर्क प्रयासों को पिछले प्रयासों के रूप में रखा है।

मैंने यह सुनिश्चित करने के लिए निम्न कोड भी जोड़ा है कि एक गतिशील बंदरगाह के लिए श्रोता है। मेरी WebRole.cs फ़ाइल में:

public class WebRole : RoleEntryPoint 
{ 
    /// <summary> 
    /// 
    /// </summary> 
    /// <returns></returns> 
    public override bool OnStart() 
    { 
     Trace.TraceInformation("OnStart method called. Updating information on IIS."); 

     try 
     { 
      // Initialize method-wide variables 
      var epName = "Endpoint6"; 
      var roleInstance = RoleEnvironment.CurrentRoleInstance; 

      // Identify direct communication port 
      var myPublicEp = roleInstance.InstanceEndpoints[epName].PublicIPEndpoint; 
      Trace.TraceInformation("IP:{0}, Port:{1}", myPublicEp.Address, myPublicEp.Port); 

      // Identify public endpoint 
      var myInternalEp = roleInstance.InstanceEndpoints[epName].IPEndpoint; 

      // Create socket listener 
      var listener = new Socket(
       myInternalEp.AddressFamily, SocketType.Stream, ProtocolType.Tcp); 

      // Bind socket listener to internal endpoint and listen 
      listener.Bind(myInternalEp); 
      listener.Listen(10); 
      Trace.TraceInformation("Listening on IP:{0},Port: {1}", 
       myInternalEp.Address, myInternalEp.Port); 

      while (true) 
      { 
       // Block the thread and wait for a client request 
       Socket handler = listener.Accept(); 
       Trace.TraceInformation("Client request received."); 

       // Define body of socket handler 
       var handlerThread = new Thread(
        new ParameterizedThreadStart(h => 
        { 
         var socket = h as Socket; 
         Trace.TraceInformation("Local:{0} Remote{1}", 
       socket.LocalEndPoint, socket.RemoteEndPoint); 

         // Shut down and close socket 
         socket.Shutdown(SocketShutdown.Both); 
         socket.Close(); 
        } 
       )); 

       // Start socket handler on new thread 
       handlerThread.Start(handler); 
      } 
     } 
     catch (Exception e) 
     { 
      Trace.TraceError("Caught exception in run. Details: {0}", e); 
     } 
     // Set the maximum number of concurrent connections 
     ServicePointManager.DefaultConnectionLimit = 12; 

     return base.OnStart(); 
    } 
} 

एक और ध्यान दें कि कॉलिंग सेवा पोर्ट 811 का उपयोग करता है सही सेवा खोजने के लिए के बाद से सेवा तीन अलग अलग WCF परियोजना स्थलों चलाता है। और जिस सेवा को मैं कॉल कर रहा हूं वह एक निर्दिष्ट पोर्ट नंबर का भी उपयोग करता है जो मुझे लगता है कि यह एक समस्या हो सकती है यदि यह अचानक गतिशील हो। कॉलिंग सेवा इस तरह दिखती है:

<endpoint address="net.tcp://myservicename.cloudapp.net:811/UserTypeService.svc" 
     behaviorConfiguration="ClientContextEndpointBehavior" binding="netTcpBinding" 
     bindingConfiguration="NetTcpBinding_FrameworkService" contract="Users.Services.IPersonTypeService" 
     name="Tcp"> 
    <identity> 
     <dns value="The Certificate Name" /> 
    </identity> 
    </endpoint> 

और प्राप्त करने (आंतरिक) वेबरोल साइटों पर मेरे पास निम्नलिखित प्रकार की कॉन्फ़िगरेशन हैं।

<service name="Core.Services.Logging.LoggingService" behaviorConfiguration="coreServiceBehavior"> 
<endpoint address="net.tcp://localhost:808/LoggingService.svc" 
       behaviorConfiguration="ContextEndpointBehavior" 
       binding="netTcpBinding" 
       bindingConfiguration="NetTcpBinding1" 
       contract="Core.Logging.ILoggingService"> 
     <identity> 
     <dns value="The Certificate Name" /> 
     </identity> 
    </endpoint> 

और बंदरगाह 811 पर अन्य WCF साइट:

<service name="Users.Services.PersonTypeService"> 
<endpoint address="net.tcp://localhost:811/UserTypeService.svc" binding="netTcpBinding" bindingConfiguration="NetTcpServiceBinding1" behaviorConfiguration="ServerContextEndpointBehavior" contract="Users.Services.IUserTypeService"> 
    <identity> 
    <dns value="The Certificate Name" /> 
    </identity> 
</endpoint> 

<endpoint address="mex" binding="mexTcpBinding" kind="mexEndpoint"> 
    <identity> 
    <dns value="localhost" /> 
    </identity> 
</endpoint> 

उत्तर

0

आप आंतरिक endpoint आईपी पते और बाहरी पते के बजाय इस्तेमाल कर सकते हैं। यहां एक उदाहरण दिया गया है:

foreach (RoleInstance roleInst in RoleEnvironment.CurrentRoleInstance.Role.Instances) 
{ 
    // Skip local role instance 
    if (RoleEnvironment.CurrentRoleInstance.Id == roleInst.Id) continue; 

    if (roleInst.Role.Name == "My Cool Role") 
    { 
     foreach (RoleInstanceEndpoint roleInstEndpoint in roleInst.InstanceEndpoints.Values) 
     { 
      // Get endpoint address using the internal endpoint's IP address 
      if (roleInstEndpoint.Protocol == "tcp") 
       SendRequest(roleInstEndpoint.IPEndpoint.Address.ToString(), command); 

     } 
    } 
} 
+0

मुझे यकीन नहीं है कि मैं अनुसरण कर रहा हूं?आप क्या सुझाव देते हैं कि मैं करता हूं और क्यों? –

+0

@MagnusKarlsson आप * बाहरी * पता myservicename.cloudapp.net का उपयोग करके _internal_ endpoint से कनेक्ट करने का प्रयास कर रहे हैं, _Input endpoints_ का उपयोग Azure के * बाहरी * से भूमिका के उदाहरणों के साथ संवाद करने के लिए किया जाता है। _ आंतरिक एंडपॉइंट्स_ का उपयोग * आंतरिक * भूमिका संचार के लिए किया जाता है और फिर आपको आंतरिक आईपी-रेंज के लिए आईपी पते की आवश्यकता होती है जो कि मेरे कोडित नमूना करता है, इसे और जानकारी के लिए देखें https://msdn.microsoft.com/en-us/library /azure/hh180158.aspx –

+0

मुझे लगता है कि Azure आंतरिक DNS मेरे क्लाउड सेवा पते को संभालेगा और इसे सही आईपी पते पर हल करेगा। चूंकि दोनों भूमिकाएं एक ही क्लाउड सेवा के भीतर हैं, इसलिए वे एक-दूसरे के साथ काम करने के बिना एक दूसरे से बात करने में सक्षम होना चाहिए? मैंने अभी इस उदाहरण के रूप में एक निश्चित बंदरगाह जोड़ा और अब इसे आजमाएं। या क्या मैं कुछ न कुछ भूल रहा हूं? https://msdn.microsoft.com/en-us/library/azure/hh180158.aspx –

संबंधित मुद्दे