Bug 25251 - WCF network exception at 60 seconds regardless of WCF binding timeout values
Summary: WCF network exception at 60 seconds regardless of WCF binding timeout values
Status: RESOLVED DUPLICATE of bug 19697
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 8.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
: 18029 ()
Depends on:
Reported: 2014-12-10 20:58 UTC by Neal
Modified: 2015-05-21 08:28 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Sample WCF test app (285.00 KB, application/zip)
2014-12-18 15:25 UTC, Neal

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Neal 2014-12-10 20:58:23 UTC

I'm using all the latest stables, Xam Studio 5.4, iOS 8.4, etc.  I'm fairly proficient in WCF, been using it for quite a few years and for the life of me I cannot figure out why in Xam iOS no matter what the binding settings I use for a basicHttp binding the connection always times out at 1 minute with a Network timeout exception.  I even tried setting client.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(5) and it still times out at 60 seconds.  I'm using WCF methods generated by the slsvcutil, I've tried both the normal style service calls as well as Task.Factory.FromAsync

Here is my binding config, the timeout is set via a property for a timespan setting.

        BasicHttpBinding Binding
                const int maxVal = 2147483647;
                var _binding = new BasicHttpBinding() { Name = "basicHttpBinding", MaxBufferSize = maxVal, MaxReceivedMessageSize = maxVal };
                _binding.ReaderQuotas.MaxDepth = maxVal;
                _binding.ReaderQuotas.MaxStringContentLength = maxVal;
                _binding.ReaderQuotas.MaxArrayLength = maxVal;
                _binding.ReaderQuotas.MaxBytesPerRead = maxVal;
                _binding.ReaderQuotas.MaxNameTableCharCount = maxVal;
                _binding.Security.Mode = BasicHttpSecurityMode.Transport;
                _binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                _binding.SendTimeout = Timeout;
                _binding.ReceiveTimeout = Timeout;
                System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;
                return _binding;

I've tried adding open and close timeout, no change

Any tips would be greatly appreciated as well as checking that the timeout setting is being honored in your implementation.

Thank you.
Comment 1 Neal 2014-12-10 21:03:04 UTC
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x0005e] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.ServiceModel.Channels.HttpRequestChannel.GotResponse (IAsyncResult result) [0x0001f] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62 
  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Byte[]].GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter_T.cs:59 
  at apdl.SyncToCoreData+<sync>c__AnonStorey4B+<sync>c__async4A.MoveNext () [0x003b8] in /Users/Neal/Dev/ncsoftware/apdlCustomContainerModel/apdl/CoreData/SyncToCoreData.cs:901
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-12-11 04:55:47 UTC
Just to be clear: you're expecting the request to timeout (for whatever reason), but the problem is that you can't specify the duration of the timeout?

In any case please attach a self-contained test project, since this may depend on several outside variables (proxy? server? etc).
Comment 3 Neal 2014-12-11 10:11:55 UTC
Rolf - I'll try to brew up a sample for you, if needed, but if you have anything to test a WCF basicHttpBinding call it should suffice.  Set all four binding timeouts to 5 minutes so they exceed the 1 minute issue I'm seeing.  Launch the app and use the Apple/XCode Link Conditioner set to 100% packet loss.  Now that you have a degraded Internet situation that should cause a timeout exception fire your service call.  Does it throw an exception at 1 minute or the timeout values on your binding?

I'm seeing that the binding timeouts are not honored and something is causing a network exception at exactly 60 seconds regardless of the WCF config.

What I need is to allow more than 1 minute for the WCF call and also have it honor anything timeout value that is explicitly set.  I even tried setting the ClientChannel.InnerChannel.OperationTimeout (or whatever it's called) and that still did not work.

Try your service call both natively as well as wrapped in a Task.Factory.FromAsync method call.

Thanks Rolf.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2014-12-18 07:53:27 UTC
Neal, the problem is really trying to setup a WCF service without a Windows machine :) A quick google search didn't reveal anything public I could use either.
Comment 5 Neal 2014-12-18 09:39:36 UTC
Rolf, thought you may have had a Xamarin WCF use sample or a unit test to ensure the WCF stack never gets broken.  I'll brew up a sample for you and follow up in a few hours.
Comment 6 Neal 2014-12-18 15:25:18 UTC
Created attachment 9133 [details]
Sample WCF test app
Comment 7 Neal 2014-12-18 15:26:28 UTC
Rolf, I googled for a sample Xamarin WCF app and picked the one off of the Xamarin web site.  I put the service on my server so you can run the app and see the issue.  As in the screenshot in the zip file you'll see I'm setting the timeout to be 2 minutes yet not matter what it will error out at 1 minute.

I'm curious to hear what you find.

Thanks Rolf,

Comment 8 Neal 2014-12-19 15:45:34 UTC
I forgot to add, I'm using the Xcode Network Link Conditioner at 100% packet loss so the app cannot communicate with the service
Comment 9 Mehmet Kartalbas 2014-12-30 03:05:23 UTC
There is already created a bug for this issue, see also to bug 19697
Comment 10 Mehmet Kartalbas 2014-12-30 03:06:30 UTC
another bug for same issue is 18029
Comment 11 Neal 2014-12-30 05:01:57 UTC
Let me add some weight to this issue and the other to help escalate the fix.  Keep in mind that we pay a significantly higher price point for WCF functionality (Pro edition).

I look forward to a quick fix.

Thank you.
Comment 12 Neal 2014-12-30 10:08:41 UTC
As you have multiple bugs reported on this I'm going to take down the WCF service I was hosting for you to see this issue since it is confirmed.
Comment 13 Rolf Bjarne Kvinge [MSFT] 2015-01-05 07:59:03 UTC

*** This bug has been marked as a duplicate of bug 19697 ***
Comment 14 Miguel de Icaza [MSFT] 2015-05-21 08:28:06 UTC
Potential workarounds:

1) client.ChannelFactory.Endpoint.Binding.SendTimeout =
TimeSpan.FromMilliseconds (1000);
2) client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds (1000);
Comment 15 Miguel de Icaza [MSFT] 2015-05-21 08:28:54 UTC
*** Bug 18029 has been marked as a duplicate of this bug. ***