title: Awaiting a service task gets TaskCanceledException: A task was canceled
body: <p>I have one app (UWP - Win10) and a Windows service. </p>
  
  <p>The service is running in background, and they were both developed in C#. "callAsync" is the method on the service. I am using await to call it on the client.</p>
  
  <pre><code>var obj = await callAsync(10);
  </code></pre>
  
  <p><strong>The problem is:</strong>
  If this call takes less than 1min40s (100 seconds), then everything works ok. But if it takes more than 1min40s, then an exception will occur "TaskCanceledException: A task was canceled".</p>
  
  <p>I have search SO and the web but still could not find any indication on how to resolve this "timeout" issue. I have added all the "open/close/receive/send" timeout flags on both app and service app.config, although the exception that is thrown in that case is different.</p>
  
  <p>If I try with a simple delay in the client: </p>
  
  <pre><code>await Task.delay(200000); 
  </code></pre>
  
  <p>it works properly.</p>
  
  <p>This service was added through VS2015 "Add Service Reference". I have also "attached" to the server and the server keeps running and prints in the console before and after logs (to confirm that everything is ok). </p>
  
  <p>What am I missing? What configuration and where do I need to change so that the task can run for more than 1 minute and 40 seconds?</p>
  
  <p><strong>CODE:</strong></p>
  
  <p><strong>Example of Server Pseudo-Code:</strong></p>
  
  <p><em>Interface File:</em></p>
  
  <pre><code>[ServiceContract(Namespace="http://.....")]
  interface ICom {
  
     [OperationContract]
     int call(int val);
  
  }
  </code></pre>
  
  <p><em>Service.cs</em></p>
  
  <pre><code>    public ServiceHost serviceHost = null;
      public BlaBlaWindowsService()
      {
          ServiceName = "BlaBlaWindowsService";
      }
  
      public static void Main()
      {
          ServiceBase.Run(new BlaBlaWindowsService());
      }
  
  
      protected override void OnStart(string[] args)
      {
          if (serviceHost != null)
          {
              serviceHost.Close();
          }
  
          serviceHost = new ServiceHost(typeof(BlaBlaService));
  
          serviceHost.Open();
      }
  
      protected override void OnStop()
      {
          if (serviceHost != null)
          {
              serviceHost.Close();
              serviceHost = null;
          }
      }
  }
  
  [RunInstaller(true)]
  public class ProjectInstaller : Installer
  {
      private ServiceProcessInstaller process;
      private ServiceInstaller service;
  
      public ProjectInstaller()
      {
          process = new ServiceProcessInstaller();
          process.Account = ServiceAccount.LocalSystem;
          service = new ServiceInstaller();
          service.ServiceName = "BlaBlaWindowsService";
          Installers.Add(process);
          Installers.Add(service);
      }
  }
  </code></pre>
  
  <p><em>BlaBlaService.cs</em></p>
  
  <pre><code>class TPAService : ITPAComunication {
  
     public int call(int val) {
  
        System.Threading.Thread.Sleep(200000)
        return 0;
     }
  
  }
  </code></pre>
  
  <p><em>App.config file:</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
  &lt;system.serviceModel&gt;
  &lt;bindings&gt;
  &lt;binding name="ServiceTimeout" closeTimeout="00:10:00" receiveTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00"/&gt;
  &lt;/bindings&gt;
          &lt;services&gt;
            &lt;service name="BlaBla.Service.Service"
                     behaviorConfiguration="ServiceBehavior"&gt;
              &lt;host&gt;
                &lt;baseAddresses&gt;
                  &lt;add baseAddress="http://localhost:8000/BlaBla/service"/&gt;
                &lt;/baseAddresses&gt;
              &lt;/host&gt;
              &lt;endpoint address=""
                        binding="basicHttpBinding"
                        bindingConfiguration="ServiceTimeout"
                        contract="BlaBla.Service.ICom" /&gt;
              &lt;endpoint address="mex"
                        binding="mexHttpBinding"
                        contract="IMetadataExchange" /&gt;
            &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
            &lt;serviceBehaviors&gt;
              &lt;behavior name="ServiceBehavior"&gt;
                &lt;serviceMetadata httpGetEnabled="true"/&gt;
                &lt;serviceDebug includeExceptionDetailInFaults="False"/&gt;
              &lt;/behavior&gt;
            &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
        &lt;/system.serviceModel&gt;
      &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>Example of App pseudo-code:</strong></p>
  
  <pre><code>System.ServiceModel.EndpointAddress epa = new System.ServiceModel.EndpointAddress("http://localhost:8000/blabla/service");
  
  System.ServiceModel.BasicHttpBinding bhb = new System.ServiceModel.BasicHttpBinding();
  
  Timespan t = new TimeSpan(0, 10, 0);
  
  bhb.SendTimeout = t; bhb.ReceiveTimeout =t; bhb.OpenTimeout = t; bhb.CloseTimeout = t;
  
  Blabla.ComunicationClient com = new Blabla.ComunicationClient(bhb, epa);
  
  var obj = await com.callAsync(int val);
  
  return obj;
  </code></pre>
  
  <p><strong>UPDATE #1</strong></p>
  
  <p>This situation only happens in UWP. I have created a similar WinForms project and everything works as expected. This means that it is probably something related to UWP.</p>