Different IP-Address on Android Emulator than on computer

Hello altogether,

In my Visual Studio Android emulator I have the following wi-fi-preferences:

My local computer wi-fi-preferences differ a little bit:

So they both unfortunately have different ip-addresses. This leads to the following error message when trying to access a local webservice (ip: http://192.168.200.231:55555/api/get) with my written android-app:

System.Net.WebException: Error: ConnectFailure (No route to host)

Is this shown because the android emulator is in a different subnet? And what can I do ? How can I change this to be able to access the webservice with my android app from the emulator?

Best regards

Answers

  • knudmtknudmt Member ✭✭
    edited December 2018

    I have read that you can access your host machine via 10.0.2.2
    So your Web Server can be running on local host and you can access your web service via http://10.0.2.2:/api/get

    if you are using IIS Express than you need to bind all host names instead of just localhost like so

    which can be done in the config of IIS Express or your app.config in your solution directory.

    If that doesnt work than try looking into Conveyor by Keyoti.

  • TBMSamTBMSam Member ✭✭
    edited December 2018

    Okay thank you all for your answers.

    The problem seems to be a little more difficult as expected :(

    I will refer to the following infrastructure: App calls webservice -> webservice reads data from database -> returns results to App -> App processes the data

    I know that my code is correct. Because if I run the emulator on my local machine, and if the webservice as well as the database run on my local machine, everything work's perfect. But if I try to run the same code on server, the app runs into timeout exceptions. The webservice always runs perfect, I can access it whencever via webbrowser/postman. But neither trying to call the webservice running on the server and the app running on my local computer nor trying to call the webservice running on the server and the app running on the server as well is successful.

    Please see following table, maybe it's easier to understand:

    Anyone any suggestions what could be the problem? Why is everything running on my local computer perfectly, but having the same code/same service on server pc, the app cannot access webservice?

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    Have you test it on an Android real device? Did you have the same issue?

Sign In or Register to comment.