Connecting Tech Pros Worldwide Forums | Help | Site Map

"Underlying connection was closed" error on windows service but only occurs when a us

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: Oct 6 '09
0I have a windows service I created that checks for data to post to an off site webservice over SSL. The service checks every 10 seconds for data to send, if there is data it opens a connection to the remote webservice, and closes the connection after 120 seconds (still checking for data to send during this time). The service works fine if a user is RDP'd into the server, but as soon as no one is logged on and the service attempts to push data, I receive the following error:
"The underlying connection was closed: An unexpected error occurred on a send."

I have tried running the service as a local service, network service, under my login, and under a service account, but nothing seems to work. Does anyone have any ideas on what may be causing this?

Here is the code in my Reference.vb - lines were added as I found possible other solutions in the forums. I am running VB .Net 3.5, developed in VS 2008 Team System. The PC it is running on is a windows 2003 server (virtualized - vmware)
Expand|Select|Wrap|Line Numbers
  1. Protected Overrides Function GetWebRequest(ByVal Uri As Uri) As System.Net.WebRequest
  2.             Dim oWebrequest As System.Net.HttpWebRequest = MyBase.GetWebRequest(Uri)
  3.  
  4.             oWebrequest.KeepAlive = False
  5.             oWebrequest.ConnectionGroupName = Guid.NewGuid.ToString
  6.             oWebrequest.ProtocolVersion = System.Net.HttpVersion.Version10
  7.             System.Net.ServicePointManager.Expect100Continue = False
  8.             System.Net.ServicePointManager.MaxServicePointIdleTime = 120000
  9.             Return (oWebrequest)
  10. End Function

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Oct 7 '09

re: "Underlying connection was closed" error on windows service but only occurs when a us


have you tried using the newer Version11 instead of Version10 ?
Reply

Tags
send, service, the underlying connection