locked
Removing Item from HealthRecord : The underlying connection was closed: An unexpected error occurred on a receive. RRS feed

  • Question


  • We have written a upload script which reads data from an external source and inserts data to HV account.
    Before inserting data to the HV account, we clear the health record.
    To do this, we individually call recordInfo.removeItems for all the ItemTypes we are using:

    e.g.

    Code Snippet

    items = fetchHVItems(Medication.TypeId);
            if (items.Count > 0)
                recordInfo.RemoveItems(items);

    where

    private HealthRecordItemCollection fetchHVItems(Guid typeID)
        {
            HealthRecordInfo recordInfo = personInfo.GetSelfRecord();
            return recordInfo.GetItemsByType
            (
                typeID,
                HealthRecordItemSections.None
            );
        }




    While executing this piece of code, we are repeatedly encountering the following exception.
    (Note: this doesn't happen everyday, but today this is very frequent)
     
    Questions:
    1. What is the reason behind the error and how do I fix it ?
    2. Is the method we are using to clear the HeathRecord correct ? Is there a better way to clear a HeathRecord ?
    3. Exception trace has references to "d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\EasyWebRequest.cs". This is not a directory on my machine !!

    System.Net.WebException was unhandled by user code
      Message="The underlying connection was closed: An unexpected error occurred on a receive."
      Source="Microsoft.Health"
      StackTrace:
           at Microsoft.Health.EasyWebRequest.WaitForCompletion() in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\EasyWebRequest.cs:line 563
           at Microsoft.Health.EasyWebRequest.Fetch(Uri url) in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\EasyWebRequest.cs:line 186
           at Microsoft.Health.EasyWebRequest.Fetch(Uri url, IEasyWebResponseHandler customHandler) in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\EasyWebRequest.cs:line 215
           at Microsoft.Health.HealthServiceRequest.ExecuteInternal() in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\WildcatClientRequest.cs:line 131
           at Microsoft.Health.AuthenticatedConnection.ExecuteRequestWithRetry(HealthServiceRequest request) in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\AuthenticatedConnection.cs:line 721
           at Microsoft.Health.HealthServiceRequest.Execute() in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\WildcatClientRequest.cs:line 116
           at Microsoft.Health.HealthRecordAccessor.RemoveItems(IList`1 itemsToRemove) in d:\enlistments\TypesAndDotNetAPI\private\prod\src\sdk\core\HealthRecordAccessor.cs:line 769
           at Migration.cleanHVAccountNoCache() in c:\HVApp\UserControls\Migration.ascx.cs:line 340
           at Migration.buttonClean_Click(Object sender, EventArgs e) in c:\HVApp\UserControls\Migration.ascx.cs:line 283
           at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
           at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Wednesday, May 21, 2008 3:41 AM

Answers

  • Recently we started seeing this "connection was closed" error and are looking into it. 

     

    I also have a concern about the scenario you presented.  Why are you deleting everything in the person's health record?  What if the data came from another app the person was using?  Or, what if they updated the data to add personal notes or something?  Generally application developers should relinquish "ownership" of the data once it has been placed in a HealthVault record.  User's can use the data in many unexpected ways once it's there.

     

    Are you trying to perform some sort of sync?  Can you tell me more about your scenario that prompted you to want to do this?

     

    Jeff Jones

    Thursday, May 22, 2008 3:23 PM

All replies

  • Recently we started seeing this "connection was closed" error and are looking into it. 

     

    I also have a concern about the scenario you presented.  Why are you deleting everything in the person's health record?  What if the data came from another app the person was using?  Or, what if they updated the data to add personal notes or something?  Generally application developers should relinquish "ownership" of the data once it has been placed in a HealthVault record.  User's can use the data in many unexpected ways once it's there.

     

    Are you trying to perform some sort of sync?  Can you tell me more about your scenario that prompted you to want to do this?

     

    Jeff Jones

    Thursday, May 22, 2008 3:23 PM
  • Yes, this sync (migration) is a one time feature which will be provided to the existing users when we move them from native database to HV.
    Friday, May 23, 2008 2:24 AM
  • Hi, Jeff

     

    While Bhuvan answered your direct question, you raised a very valid point (What if the data came from another app the person was using? ), which makes sense in any "multi-user" environment. Our specific case (debugging the complex transfer of large amount of data to and from HealthVault) is not frequent enough to warrant HealthVault support for transactions, nor do I expect to find the API like "delete everything I added in last 10 minutes".

     

    My point here is that the current scenario (one time database sync) is not the only one which requires "delete all my data". One of our projects is a model of the Health Record Bank, where data import and export are regular actions - just like in financial banks.

     

    Do you have any recommendations (other than "be very carefull" :-)

     

    Nik

    Friday, June 20, 2008 1:09 AM