简体   繁体   中英

Why can't I hit my WCF service from the outside of the machine, but I can locally?

I have a WCF Self Hosted service running on a machine with IIS configured. The self hosted service starts with no problem and I can actually access the ?wsdl path once it is up and running.

If I try to hit the following addresses on the machine it loads up the Web page talking about svcutil.exe and how to access the service.

http://myspecialservice:9000/
http://192.168.1.230:9000/

However, if I try to hit that same address from another machine. I get nothing. No errors, the page just can't be loaded. And I have tested to make sure I am resolving to the right IP Address when I use the hostname.

Also, I have configured for the .exe of the service to be allowed in Windows Firewall With Advanced Security. For all Ethernet Profiles, and any port. Any advice would help out a lot. Again, I know the service is accessible locally on the machine and that it works properly. It seems I am missing a machine configuration somewhere.

<?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="TextWriter" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log"/>
        <add name="Console" type="System.Diagnostics.ConsoleTraceListener"/>
        <remove name="Default"/>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="CustomHttpBinding" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client/>
    <services>
      <service name="MyService.Data.Service" behaviorConfiguration="serviceBehavior">
        <clear/>
        <endpoint address="JobsHttp" binding="basicHttpBinding" contract="MyService.Data.IWhereItSits" bindingConfiguration="CustomHttpBinding"></endpoint>
        <endpoint binding="mexHttpBinding" name="httpmex" contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://myspecialservice:9000/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

EDIT 1

So opening up port 9000 on the firewall instead of specifying a rule for the service.exe allowed me to hit the service on the local network. Now I am trying to hit the service from the outside world. I have added a rule to my router to push any traffic from port 9000 to the server itself but I am not getting anything.

EDIT 2

I have installed Network Monitor onto the web server and I can confirm that the router is passing the traffic back to the server itself. And then the server tries to send a response back.

EDIT 3

Makes no sense to me whatsoever. The server has two nics, I was targeting 1 IP from the router to the server. I changed it to the other IP and it works from the outside, any explanations or answers?

You say in your edits that you were able to reach your server, but 192.168.1.230 is a local address. It is only valid from within your local network. Your ip address for the outside world is different. :/


Edit

What is your IIS listening to? Maybe you have your bindings (IIS->your site->right click->Edit bindings) set to the other ip only. If so changing IP Address to 'All Unasigned' should make your service respond the first ip as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM