weird error

P

Param R.

Hi all, I have a web service that opens a sqlconnection to the db and does
some work. The other day for the first time for about 30 mins I started
getting the following error message:

Timeout expired.The timeout period elapsed prior to obtaining a connection
from the pool.This may have occurred because all pooled connections were in
use and max pool size was reached.

Any ideas what this means and how to prevent in the future?

thanks,
Param
 
C

CT

Not sure, but it seems your Web service is not closing the connection and
returning them to the pool. Do you explicitly close your connections in your
Web service?
 
P

Param R.

Yes. Conn.Close() Conn.Dispose()

CT said:
Not sure, but it seems your Web service is not closing the connection and
returning them to the pool. Do you explicitly close your connections in
your Web service?
 
S

Sahil Malik

Pretty clear that somehow the connection is not being closed. I read your
other message saying that you did call close & dispose, but that is most
definitely the reason. If the code wont' take 3 days to read, can you paste
it here?
Also, if you are using dataadapter, then don't open the explicitly
connection at all.

Another remote far fetched possibility could be that your webservice is hit
by so many requests suddenly that it does actually have too many open
connections at the same time - in which case you can increase the pool size
in the connection string. But we're talkin' a whole damn lot of requests
here :)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
C

CT

Can you verify that the code is being called? Use remote debugging or if
that's out of the question perhaps you can add some temporary code to log en
event to the event log?
 
P

Param R.

Sahil, this is the first time has happened in a year! We have had some
serious load in the past and never this error message. Now how many requests
would be a whole lot of requests? Also, what do you mean by "Also, if you
are using dataadapter, then don't open the explicitly connection at all."

Below is a code snippet of the webservice class. I have a custom dll that
opens the connection when instantiated and closes it when destroyed.

WEB SERVICE:

<WebService(Namespace := "https://url")> Public Class MyWebService
Inherits Webservice

Private strdsn as string
Private objDB as dbClass

Public Sub New()
strdsn = ConfigHelper.GetValueFromConfigFile("DSN")
objDB = new dbClass(strdsn)
End Sub

Sub Destruct()
objDB.dispose()
objDB = Nothing
End Sub

End Class



DB CLASS:

Public Class DBClass
Implements IDisposable

Private objConnect as SqlConnection
Private objTrans as SQlTransaction
Private logName, sourceName as string
Private objLog as logClass
Private logError as Boolean

Public Sub New(byval strdsn as string)
logError = False
logName = ConfigHelper.GetValueFromConfigFile("LogName")
sourceName = ConfigHelper.GetValueFromConfigFile("SourceName")
if (len(logName) > 0 and len(sourceName) > 0) Then
logError = True
objLog = new logClass(logname, sourcename)
end if

if len(strdsn) = 0 Then
throw new ServicesException("No dsn string passed in constructor
statement.", 1)
end if

Try
objConnect = new SqlConnection(strdsn)
objConnect.Open
Catch objException as InvalidOperationException
if logError Then objLog.LogEvent(GetErrorMessage(objException.Message),
eventlogentrytype.error)
throw new ServicesException("Connection to database cannot be opened: no
server specified OR connection is already open.")
Catch objException as SQLException
if logError Then objLog.LogEvent(GetErrorMessage(objException.Message),
eventlogentrytype.error)
throw new ServicesException("Connection to database could not be
established. The server maybe down.")
End Try
End Sub

Public Sub Dispose() Implements System.IDisposable.Dispose
objConnect.dispose()
if logError Then objLog = Nothing
End Sub

End Class
 
S

Sahil Malik

Param, what I meant by the data adapter comment was, that the data adapter
will ensure a connection is opened used and duly closed, if it found the
connection as closed before it started working on it. So if you never open
the connection, you can be sure there are none open left.

The code below shows a webservice, which of the methods is a webmethod?
Specifically which webmethod is giving you problems when repeatedly called?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
Please reply to the newsgroups instead of email so everyone can benefit from
your reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top