Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble connecting to wcf service on localhost from Android emulator

I'm building an app with Xamarin Studio that's supposed to access a wcf service. Accessing the service works fine from my browser with the following url: http://localhost:52277/api

Whenever I try to access it from my android code, I get the following exception:

System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Exception: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
  at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[String] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00051] in c:\Users\nicklas.winger\Documents\GitHub\ServiceStack\src\ServiceStack.Common\ServiceClient.Web\ServiceClientBase.cs:896

I'm running the service on IIS express, and I've modfied my iis applicationhost.config like this (Removing 'localhost' from bindingInformation, according to a course on pluralsight):

<site name="ProteinTrackerMvc" id="45">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="c:\users\nicklas.winger\documents\visual studio 2012\Projects\ProteinTrackerMvc\ProteinTrackerMvc" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:52277:" />
    </bindings>
</site>

Also, my web service is building and deploying using iis express at the mentioned port. Any suggestions to what I might be doing wrong? :)

like image 311
Nicklas Pouey-Winger Avatar asked Oct 06 '13 18:10

Nicklas Pouey-Winger


1 Answers

Solved by using the following ip: 10.0.2.2 instead of localhost.

like image 122
Nicklas Pouey-Winger Avatar answered Nov 11 '22 16:11

Nicklas Pouey-Winger