Reputation: 864
I have a self-hosted REST service (in C#) which works perfectly in my local network, but is unreachable remotely. Here is my hosting code:
static Uri baseAddress = new Uri("http://m.y.i.p:8080");
WebServiceHost serviceHost = new WebServiceHost(typeof(WebService.RestService),
baseAddress);
serviceHost.Open();
(Which is run in Windows Forms, BTW).
Here is App.Config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
</bindings>
<services>
<service name="WebService.RestService" behaviorConfiguration="Default">
<host>
<baseAddresses>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding"
behaviorConfiguration="webBehavior"
contract="WebService.ICarga">
</endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
When, in a browser, I enter 10.1.1.1:8080/test, it shows exactly what I want. But when I type m.y.i.p:8080/test, it is unreachable. Firewall is off, I'm running as administrator and already tried the netsh command. Port 8080 is correctly forwarded to my PC. How can I make this accessible remotely?
Thanks.
EDIT: For people looking into this in the future, I had a problem with my router (my ip changed, and I didn't change it in the router). Everything should work if you define your App.config right. If you have this problem, double check your code, be sure that your network is working the way you expect it to, if needed turn off firewall and if you're not administrator, use the answer to this question or this MS page to own your desired port.
Upvotes: 0
Views: 1348
Reputation: 35363
Change
new Uri("http://m.y.i.p:8080");
to
new Uri("http://0.0.0.0:8080");
Upvotes: 1