Error: The underlying connection was closed.

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Miros
Posts: 45
Joined: Thu 20 Jan 2011 10:12
Contact:

Error: The underlying connection was closed.

Post by Miros » Fri 24 Jun 2011 07:48

We are implementing a webservice (WCF) that uses dotConnect MySQL Entity Framework - LINQ to SQL - to access data.

We have a service method that returns a relational entity object "Company" from the datamodel, but the method throws the following error:

"The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."

It looks like the error occurs because the Company object has a collection of other entity objects "CompanyModules". We tried to set the CompanyModules collection to NULL before returning the entity object and then the error does not occur, but obviously this is not desirable.

Do you have any idea why this is occuring, and if possible how to go about it while maintaining the entity relations?

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 27 Jun 2011 08:19

Could you please specify whether you are working with an Entity Framework or LinqConnect model when this issue occurs? Also, please specify the exception stack trace.

Miros
Posts: 45
Joined: Thu 20 Jan 2011 10:12
Contact:

Post by Miros » Mon 27 Jun 2011 13:05

StanislavK wrote:Could you please specify whether you are working with an Entity Framework or LinqConnect model when this issue occurs? Also, please specify the exception stack trace.
We are working with LinqConnect, and here is StackTrace:

System.Net.WebException.Message: "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."

System.Net.WebException.StackTrace:

Code: Select all

   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at nSales.ServiceClient.Test.WSTest.GetCompany(String accountName) in E:\Mikkel\Dokumenter\Visual Studio 2010\Projects\nSales WebService\nSales.ServiceClient\Web References\Test\Reference.cs:line 114
   at nSales.ServiceClient.Form1.button_GetCompany_Click(Object sender, EventArgs e) in E:\Mikkel\Dokumenter\Visual Studio 2010\Projects\nSales WebService\nSales.ServiceClient\Form1.cs:line 141
System.Net.WebException.InnerException.Message: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."

System.Net.WebException.InnerException.StackTrace:

Code: Select all

   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 29 Jun 2011 14:26

I've sent you a test project in a letter, please check that it was not blocked by your mail filter. To run the sample, please perform the following:
- create the tables (please see the letter for the scripts);
- set the proper connection string in the service project;
- publish the service;
- update the service reference in the console application.

Please tell us whether the test project runs properly in your environment. If yes, please specify what should be changed in the sample to reproduce the problem, or send us your test project.

Post Reply