locked
The underlying connection was closed: The connection was closed unexpectedly. WCF data service and Sql Azure RRS feed

  • Question

  • Hi all,

    I am getting following exception in _datacontext.savechanges();

    The underlying connection was closed: The connection was closed unexpectedly.

    I am using wcf data service and sql azure and that wcf data sevice create the role in azure.

    now i am getting above exception not regular but some times so my code work some time i didnot understant what problem occurred so i got this error message. i am sure that connection is not closed but still it says connection was closed.
    Thursday, March 21, 2013 12:34 PM

All replies

  • I have faced this problem too and in my case it was related to network

    To mitigate this you may try Retry logic i.e.

    try

    {SaveChanges()

    }

    catch

    {

    sleep(100)

    //Try onece more after a timeout 

    SaveChanges()

    }

    Friday, March 22, 2013 5:01 AM