title: WCF TimeoutException despite stepping through showing successful return
body: <p>I have two self hosted services running on the same network. The first is sampling an excel sheet (or other sources, but for the moment this is the one I'm using to test) and sending updates to a subscribed client.
  The second connects as a client to instances of the first client, optionally evaluates some formula on these inputs and the broadcasts the originals or the results as updates to a subscribed client in the same manner as the first. All of this is happening over a tcp binding.</p>
  
  <p>My problem is occuring when the second service attempts to subscribe to two of the first service's feeds at once, as it would do if a new calculation is using two or more for the first time. I keep getting TimeoutExceptions which appear to be occuring when the second feed is subscribed to. I put a breakpoint in the called method on the first server and stepping through it, it is able to fully complete and return true back up the call stack, which indicates that the problem might be some annoying intricacy of WCF</p>
  
  <p>The first service is running on port 8081 and this is the method that gets called:</p>
  
  <pre><code>public virtual bool Subscribe(int fid)
  {
      try
      {
          if (fid &gt; -1 &amp;&amp; _fieldNames.LeftContains(fid))
          {
              String sessionID = OperationContext.Current.SessionId;
              Action&lt;Object, IUpdate&gt; toSub = MakeSend(OperationContext.Current.GetCallbackChannel&lt;ISubClient&gt;(), sessionID);//Make a callback to the client's callback method to send the updates
              if (!_callbackList.ContainsKey(fid))
                  _callbackList.Add(fid, new Dictionary&lt;String, Action&lt;Object, IUpdate&gt;&gt;());
              _callbackList[fid][sessionID] = toSub;//add the callback method to the list of callback methods to call when this feed is updated
              String field = GetItem(fid);//get the current stored value of that field
              CheckChanged(fid, field);//add or update field, usually returns a bool if the value has changed but also updates the last value reference, used here to ensure there is a value to send
              FireOne(toSub, this, MakeUpdate(fid, field));//sends an update so the subscribing service will have a first value
              return true;
          }
          return false;
      }
      catch (Exception e)
      {
          Log(e);//report any errors before returning a failure
          return false;
      }
  }
  </code></pre>
  
  <p>The second service is running on port 8082 and is failing in this method:</p>
  
  <pre><code>public int AddCalculation(string name, string input)
  {
      try
      {
          Calculation calc;
          try
          {
              calc = new Calculation(_fieldNames, input, name);//Perform slow creation before locking - better wasted one thread than several blocked ones
          }
          catch (FormatException e)
          {
              throw Fault.MakeCalculationFault(e.Message);
          }
          lock (_calculations)
          {
              int id = nextID();
              foreach (int fid in calc.Dependencies)
              {
                  if (!_calculations.ContainsKey(fid))
                  {
                      lock (_fieldTracker)
                      {
                          DataRow row = _fieldTracker.Rows.Find(fid);
                          int uses = (int)(row[Uses]) + 1;//update uses of that feed
                          try
                          {
                              if (uses == 1){//if this is the first use of this field
                                  SubServiceClient service = _services[(int)row[ServiceID]];//get the stored connection (as client) to that service
                                  service.Subscribe((int)row[ServiceField]);//Failing here, but only on second call and not if subscribed to each seperately
                              }
                          }
                          catch (TimeoutException e)
                          {
                              Log(e);
                              throw Fault.MakeOperationFault(FaultType.NoItemFound, "Service could not be found");//can't be caught, if this timed out then outer connection timed out
                          }
                          _fieldTracker.Rows.Find(fid)[Uses] = uses;
                      }
                  }
              }
              return id;
          }
      }
      catch (FormatException f)
      {
          Log(f.Message);
          throw Fault.MakeOperationFault(FaultType.InvalidInput, f.Message);
      }
  }
  </code></pre>
  
  <p>The ports these are on could change but are never shared. The tcp binding used is set up in code with these settings:</p>
  
  <pre><code>_tcpbinding = new NetTcpBinding();
  _tcpbinding.PortSharingEnabled = false;
  _tcpbinding.Security.Mode = SecurityMode.None;
  </code></pre>
  
  <p>This is in a common library to ensure they both have the same set up, which is also a reason why it is declared in code.</p>
  
  <p>I have already tried altering the Service Throttling Behavior for more concurrent calls but that didn't work. It's commented out for now since it didn't work but for reference here's what I tried:</p>
  
  <pre><code>ServiceThrottlingBehavior stb = new ServiceThrottlingBehavior
  {
      MaxConcurrentCalls = 400,
      MaxConcurrentSessions = 400,
      MaxConcurrentInstances = 400
  };
  host.Description.Behaviors.RemoveAll&lt;ServiceThrottlingBehavior&gt;();
  host.Description.Behaviors.Add(stb);
  </code></pre>
  
  <p>Has anyone had similar issues of methods working correctly but still timing out when sending back to the caller?</p>