1

I am using the Azure Mobile App quickstart ToDoList example to get started with cross platform app. I have set up the back-end and it is working on localhost - I can hit it using Swagger and gets posts etc are working.

I then set up the client application (Xamarin.Forms). I am running the client application on my Android device and all works great when back-end is in Azure, including the offline sync element. The problem is that I have to work locally for now but I cannot sync with the db when running on localhost.

At first the debugger was giving me a "connection refused" error, so I followed the steps here and in various other sources including using my laptop IP and setting firewall rule, adding binding to port in IIS Manager and applicationhost.config, and changing ApplicationURL in Constants.cs.

Now, I get no connection refused error, but the data is not getting to the db, athough the localdb on the tablet seems to be working - it is failing when I try to sync to/from db.

Not too familiar with networking but it may be important to note that when I use localhost:portnum/tables/todoitem in browser I get results in XML but when I use 192.168.0.10:portnum/tables/todoitem I get "Bad Request - Invalid Hostname".

Community
  • 1
  • 1
Inkers
  • 219
  • 7
  • 27

1 Answers1

1

By default, your Mobile App .NET server backend application will run in IIS Express. This is problematic when debugging with a client application running in another device on your network, or in a virtual machine in Hyper-V (such as Windows Phone Emulator). IIS Express will host your server application under localhost, which makes the application unreachable to other devices or virtual machines. Your client application running on Windows Phone Emulator has a different meaning for localhost. The same is true for the Visual Studio Emulator (which runs in Hyper-V) and the Google Emulator.

It is simpler to configure your machine to host your Mobile App .NET server backend application on IIS, as this allows you to control the binding of the server application to an IP address, rather than localhost.

For information on this, see: https://github.com/Azure/azure-mobile-apps-net-server/wiki/Local-development-and-debugging-the-Mobile-App-.NET-server-backend

Adrian Hall
  • 7,990
  • 1
  • 18
  • 26
  • Thanks Adrian. A good bit to get through there. I will give it a try and revert back. – Inkers Aug 11 '16 at 18:07
  • Only getting back to this now. I have followed the steps for connecting to IIS and can now get the app homepage via the IP from my device. However, when I try to perform any get, post etc via swagger I am getting a server error (500). "The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections." Struggling to understand what is wrong. – Inkers Aug 17 '16 at 14:34
  • You will need to debug the 500, which is generally a server code problem. There is likely an exception being thrown in your code that you are not trapping appropriately. – Adrian Hall Aug 17 '16 at 23:01