Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin.iOS - consuming a WCF service hosted locally results in timeout

JeffRushJeffRush USMember ✭✭✭
edited August 2018 in Xamarin.iOS

First of all, this problem does NOT occur when I access the same WCF service hosted on my Azure account. The problem only occurs when hosting locally.

The WCF service is hosted on my local IIS account. I've successfully tested it using this C# code in a WinForms app:

        ServiceReference1.myService client = new ServiceReference1.myServiceClient();
        var response = client.Authenticate("xxxx", "yyyy");

In my Xamarin.iOS app (using Visual Studio 2017 on a Windows 10 machine connected to a Mac), I have my local .cs file created using slsvcutil. I also have a proxy class that looks like this:

        public class WCFClientProxyFactory
            //private static readonly EndpointAddress _Endpoint = new EndpointAddress("");
            private static readonly EndpointAddress _Endpoint = new EndpointAddress(_my azure url_);

            public static myServiceClient CreateWCFClientProxy()
                myServiceClient client;
                BasicHttpBinding binding = CreateBasicHttp();
                client = new myServiceClient(binding, _Endpoint);
                return client;

            private static BasicHttpBinding CreateBasicHttp()
                BasicHttpBinding binding = new BasicHttpBinding
                    Name = "basicHttpBinding", MaxBufferSize = 2147483647, MaxReceivedMessageSize = 2147483647
                TimeSpan timeout = new TimeSpan(0, 0, 30);
                binding.SendTimeout = timeout;
                binding.OpenTimeout = timeout;
                binding.ReceiveTimeout = timeout;
                return binding;

Everything works if the azure Endpoint is used. If I use the local url, I get this error:

{System.TimeoutException: The operation has timed out. at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_delegate_end_invoke(object,intptr) at (wrapper delegate-end-invoke) .end_invoke_object__this___object[]&_IAsyncResult(object[]&,System.IAsyncResult).......... (it goes on for a while)

I've tried turning off my Windows firewall since the request is coming from an external source (Mac). But no change.

Any help is appreciated...


  • ArindamSarkarArindamSarkar Member ✭✭

    @JeffRush , it could be because of IP address or HTTP schema. Please check if HTTP call allowed in iOS App config. I doubt if WCF call reaching to server at all from iOS.

  • JeffRushJeffRush USMember ✭✭✭

    Yeah, the problem seems to be that the Mac doesn't "see" the PC's localhost. I will try to modify the configuration so that it can. Thanks...

  • BushbertBushbert Member ✭✭✭

    I guess your starting point is to see if it works from your macs browser. This will isolate whether it’s a network issue or an app issue.

    When you say local IIS account, do you mean IIS or IIS express? If using IIS express, you may need to add a binding for your local IP address.

    You are accessing the local service on port 80, is that right? If IIS express, this is usually a different port.

    Just some thoughts.

Sign In or Register to comment.