Stopping and restarting a VB.NET Windows Service

G

Gene

I have a Windows Service (VB.NET) that runs 24/7. It
queries a Web service 5 to 10 times per hour. About 2 or
3 times a month, it fails. The log indicates that it
sends the request to the Web service but there is no
return from the service. Stopping and restarting the
Windows service cures the problem.

Our desire is to cure the problem with appropriate error
handling but failing that, is there an easy way to
automatically stop and restart the Windows service either
from within the service, from Windows, or from a parallel
Windows service that does nothing but monitor the primary
Windows Service to stop and restart it when necessary.

Any help, feedback, or comments would be appreciated.
 
F

Fergus Cooney

Hello Gene,

I'm no expert on this but no one else has given you a solution
yet.

I would expect a Windows Service to be able to stop itself, but
not to be able to start itself (because it wouldn't be running!).

Another Windows Service to monitor it would work but sounds like a
last-resort workaround. If you went this way I think you need to look
into the WMI classes which effect what you do manually with the
Computer Management Console.
Help topic:
ms-help://MS.MSDNVS/cpguide/html/cpconusingwmiwiththenetframework.htm
But get further advice - like I say, this is not my area.

I think the best solution, certainly from the point of view of
peace of mind, is to put your effort to dealing with the error.

You say that there is no return from your request. Some questions:

Do you know this because of a time-out or otherwise?
What happens next - does your Service crash?
Do all subsequent requests similarly fail?
Is an Exception thrown?
Are you logging everything that may be useful or just minimal
activity/status info?
Etc - whatever info you think might be relevant.

Regards,
Fergus
 
F

Fergus Cooney

Hi again,

If I'd known you had done two posts on the same topic...

It's a good idea to post second thoughts as a reply to your
original query. Makes it easier for us. We don't have to ask for more
information only to find it on an earlier (but further down the page)
query. And under a different name, too!

Never mind :)

============================
Some more thoughts.

WebService is inherited from
System.ComponentModel.MarshalByValueComponent.
This has a member GetService which is an implementor of the
IServiceProvider.
GetService has a member HttpContext.
HttpContext has all sort of goodies.

Even if this is a wrong avenue, they is a whole host of stuff to
be checked out in WebService's ancestry. You may well find somethig to
do with error handling, timeouts, connection life spab, etc.

Happy hunting,
Fergus
 
C

Cor

Fergus,
Because I asume 80% change it has to do with the net framework or IIS is
making a solution to track that for me as putting a horse after the car
(don't know if this proverb exist in the English language, but because you
too did use reckon and lives on the south westcoast from England, maybe you
uses that too). But if someone would give help here I did not say not to do
that, my advise was put your question too in the asp.net group.
Cor
 
F

Fergus Cooney

Hi Cor,

Yes it may well be on the IIS side, or it may be the Windows Service side.
Let's hope he finds out.

|| putting a horse after the car

Almost there in spelling but quite different in meaning. :)

"put the horse after the <cart>" is used for situations which are (usually
ridiculously) reversed.

Regards,
Fergus

ps. I've asked before and you missed the question, but I'm curious so I'll ask
again - what country do you come from ?
 
G

Gene

To Cor and Fergus:

Thank you for your comments. Here are some answers to
your comments.

(1) I am posting these questions to the
microsoft.public.dotnet.framework.webservices. Thanks for
the tip. I found that location by searching for "ASP.NET"
and finding the most frequently used site.

(2) Neither the Windows Service or Web Service has any
ASP.NET associated with them.

(3) I posted these separately because the problems are
independent of each other. In one case, it happens
whenever we go more than 30 minutes without a transaction
being sent by server. We have error trapping and the
system functions. It just causes an automatic
resubmission and a delay in the process (which makes the
end user wait longer than expected). During the busy time
of day there is no problem because the requests go every
10 or 15 minutes. During slower part of day, there can be
a 60 minute gap between requests.

The second problem happens sporatically perhaps once every
week or two at one location (out of 10). We have no idea
about what causes it. We have never seen it happen when
being closely monitored or tested. So far, our error
trapping has not yielded any clues and we have no idea of
how to duplicate the problem. (We only know how to fix it
(stop and restart windows service.) Who knows when it
will happen again?

Gene
 
C

Cor

Hi Gene,
I did wish I could help you but I cannot.
I see in no way a connection to the Vb.net language other than that a VB.DLL
is used as last part of the string.
I think that this can happen everywhere from your connection provider till
your program.
In your IIS (I doupt but it can)
In your Asp.net webserver part
In your operating system (balance load or something?)
Maybe you can write a program to check this, but I think the best part of
that will be that it helps you to find the problem.
When your program is ready I think the problem is gone.
Sorry I cannot help you, but lots of succes
Cor
 

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