title: How to handle "Unexpected EOF at target" error from API calls?
body: <p>I'm creating a Forge application which needs to get version information from a BIM 360 hub. Sometimes it works, but sometimes (usually after the code has already been run once this session) I get the following error:</p>
  
  <pre><code>Exception thrown: 'Autodesk.Forge.Client.ApiException' in mscorlib.dll
  Additional information: Error calling GetItem: {
    "fault":{
      "faultstring":"Unexpected EOF at target",
      "detail": {
        "errorcode":"messaging.adaptors.http.flow.UnexpectedEOFAtTarget"
      }
    }
  }
  </code></pre>
  
  <p>The above error will be thrown from a call to an api, such as one of these:</p>
  
  <pre><code>dynamic item = await itemApi.GetItemAsync(projectId, itemId);
  dynamic folder = await folderApi.GetFolderAsync(projectId, folderId);
  var folders = await projectApi.GetProjectTopFoldersAsync(hubId, projectId);
  </code></pre>
  
  <p>Where the apis are initialized as follows:</p>
  
  <pre><code>ItemsApi itemApi = new ItemsApi();
  itemApi.Configuration.AccessToken = Credentials.TokenInternal;
  </code></pre>
  
  <p>The Ids (such as 'projectId', 'itemId', etc.) don't seem to be any different when this error is thrown and when it isn't, so I'm not sure what is causing the error. </p>
  
  <p>I based my application on the .Net version of this tutorial: <a href="http://learnforge.autodesk.io/#/datamanagement/hubs/net" rel="nofollow noreferrer">http://learnforge.autodesk.io/#/datamanagement/hubs/net</a></p>
  
  <p>But I adapted it so I can retrieve multiple nodes asynchronously (for example, all of the nodes a user has access to) without changing the jstree. I did this to allow extracting information in the background without disrupting the user's workflow. The main change I made was to add another Route on the server side that calls "GetTreeNodeAsync" (from the tutorial) asynchronously on the root of the tree and then calls it on each of the returned children, then each of their children, and so on. The function waits until all of the nodes are processed using Task.WhenAll, then returns data from each of the nodes to the client;</p>
  
  <p>This means that there could be many api calls running asynchronously, and there might be duplicate api calls if a node was already opened in the jstree and then it's information is requested for the background extraction, or if the background extraction happens more than once. This seems to be when the error is most likely to happen. </p>
  
  <p>I was wondering if anyone else has encountered this error, and if you know what I can do to avoid it, or how to recover when it is caught. Currently, after this error occurs, it seems that every other api call will throw this error as well, and the only way I've found to fix it is to rerun the code (I use Visual Studio so I just rerun the server and client, and my browser launches automatically)</p>