473,378 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

windows service not starting threads on newly deployed server

I have a windows service that kicks off a 'monitor' thread which in
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors (exceptions)
to the monitor thread.

Of course, all works well on my box. Yesterday I installed the .NET
Framework 1.1 on a new server and then installed my service. It
appears that everything is starting but when I perform a netstat - a
searching for my 4 ports, I don't see them 'listening'. Via Task
Manager... I added the Thread Count column and see that 6 threads are
running. I compare this to my box and 11 threads are running. Not
sure if this even applies but I don't know how to remotely trouble
shoot this issue. I really need to figure out why these 4 threads are
starting. thanks for the help!

code snippet...

Also, this is portion of the code so if it's confusing let me know.

protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
this._serviceRunning = true;
ThreadStart ts = new ThreadStart( this.Monitor );
Thread myWorkerThread = new Thread( ts );
myWorkerThread.Name = "MonitorThread";
myWorkerThread.Start();
}

within Monitor...

Hl7Listener[] hl7listener = new Hl7Listener[ls.Length];
threadArray = new Thread[ls.Length];

for (i=0;i<ls.Length;i++)
{
hl7listener[i] = new Hl7Listener(ls[i].Port);
hl7listener[i].Priority = ls[i].Priority;
hl7listener[i].SiteMsgPrefix = ls[i].MsgPrefix;
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].IsBackground = true;
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}

// member variable set to false within OnStop()
while (this._serviceRunning)
{
for (i=0;i<this.threadCount;i++)
{
if (hl7listener[i].ExceptionString != "")
{
this.eventLog1.WriteEntry("Exception handled on on thread port " +
Convert.ToString(ls[i].Port) +
hl7listener[i].ExceptionString, EventLogEntryType.Error);
hl7listener[i].ExceptionString = "";
if (threadArray[i].IsAlive)
{
hl7listener[i].Stop();
threadArray[i].Abort();
threadArray[i] = null;
}
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}
}
Thread.Sleep(10000);
}
Nov 15 '05 #1
2 1860
Hi Karl,

I assume that you did a telnet to one of those ports, right?
Are none of them listening?
Did you check that there are not other services already listening on those
ports?
How are you creating the Listener object, maybe you have hardcoded your
box PC's IP. and tis is giving you problem as it;s not valid on the new
machine.

If none of the above solve your problem I would try to see if an exception
is being generated, The exception is not propagated to the parent thread so
you will have to put a mechanism in the thread code to check for them, maybe
write it to the log or dump it to a file.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"karl" <ka**********@tricaresw.af.mil> wrote in message
news:d2*************************@posting.google.co m...
I have a windows service that kicks off a 'monitor' thread which in
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors (exceptions)
to the monitor thread.

Of course, all works well on my box. Yesterday I installed the .NET
Framework 1.1 on a new server and then installed my service. It
appears that everything is starting but when I perform a netstat - a
searching for my 4 ports, I don't see them 'listening'. Via Task
Manager... I added the Thread Count column and see that 6 threads are
running. I compare this to my box and 11 threads are running. Not
sure if this even applies but I don't know how to remotely trouble
shoot this issue. I really need to figure out why these 4 threads are
starting. thanks for the help!

code snippet...

Also, this is portion of the code so if it's confusing let me know.

protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
this._serviceRunning = true;
ThreadStart ts = new ThreadStart( this.Monitor );
Thread myWorkerThread = new Thread( ts );
myWorkerThread.Name = "MonitorThread";
myWorkerThread.Start();
}

within Monitor...

Hl7Listener[] hl7listener = new Hl7Listener[ls.Length];
threadArray = new Thread[ls.Length];

for (i=0;i<ls.Length;i++)
{
hl7listener[i] = new Hl7Listener(ls[i].Port);
hl7listener[i].Priority = ls[i].Priority;
hl7listener[i].SiteMsgPrefix = ls[i].MsgPrefix;
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].IsBackground = true;
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}

// member variable set to false within OnStop()
while (this._serviceRunning)
{
for (i=0;i<this.threadCount;i++)
{
if (hl7listener[i].ExceptionString != "")
{
this.eventLog1.WriteEntry("Exception handled on on thread port " +
Convert.ToString(ls[i].Port) +
hl7listener[i].ExceptionString, EventLogEntryType.Error);
hl7listener[i].ExceptionString = "";
if (threadArray[i].IsAlive)
{
hl7listener[i].Stop();
threadArray[i].Abort();
threadArray[i] = null;
}
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}
}
Thread.Sleep(10000);
}

Nov 15 '05 #2
"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us> wrote in message news:<eo*************@TK2MSFTNGP11.phx.gbl>...
Hi Karl,

I assume that you did a telnet to one of those ports, right?
Are none of them listening?
I'm replacing a VB app that utilizes the same ports. I can start the
VB app and see that the ports are listening. I then shutdown the VB
app, confirm that nobody else is using the ports and then start up my
..NET app.
Did you check that there are not other services already listening on those
ports?
How are you creating the Listener object, maybe you have hardcoded your
box PC's IP. and tis is giving you problem as it;s not valid on the new
machine.
No hardcoding of any ip.

If none of the above solve your problem I would try to see if an exception
is being generated, The exception is not propagated to the parent thread so
you will have to put a mechanism in the thread code to check for them, maybe
write it to the log or dump it to a file.

My HL7Listener is derived from the TCPListener. I've added various
methods and fields. One field is an ExceptionString which stores any
exception that is thrown. The Monitor thread then checks to see if
this field has something in it so it can write it to the event log,
shutdown the listener, abort the thread and then create a new one.
Since this is my first attempt at working at threads, I realize that I
may be doing some overkill but I'm learning.

I'm using the InstallUtil.exe to install the service. I did find some
info about the .NET Security and found that there are special rules
relating to who can use a socket and such. Still investigating. I
was praying that I just needed to put something into the gac or
whatever it's called.

Oh yeah, I performed the same steps on another server and am having
the exact same problems. These servers are locked down due to C2
Certification so there may be something related to the accounts access
or the server access. Unknown.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"karl" <ka**********@tricaresw.af.mil> wrote in message
news:d2*************************@posting.google.co m...
I have a windows service that kicks off a 'monitor' thread which in
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors (exceptions)
to the monitor thread.

Of course, all works well on my box. Yesterday I installed the .NET
Framework 1.1 on a new server and then installed my service. It
appears that everything is starting but when I perform a netstat - a
searching for my 4 ports, I don't see them 'listening'. Via Task
Manager... I added the Thread Count column and see that 6 threads are
running. I compare this to my box and 11 threads are running. Not
sure if this even applies but I don't know how to remotely trouble
shoot this issue. I really need to figure out why these 4 threads are
starting. thanks for the help!

code snippet...

Also, this is portion of the code so if it's confusing let me know.

protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
this._serviceRunning = true;
ThreadStart ts = new ThreadStart( this.Monitor );
Thread myWorkerThread = new Thread( ts );
myWorkerThread.Name = "MonitorThread";
myWorkerThread.Start();
}

within Monitor...

Hl7Listener[] hl7listener = new Hl7Listener[ls.Length];
threadArray = new Thread[ls.Length];

for (i=0;i<ls.Length;i++)
{
hl7listener[i] = new Hl7Listener(ls[i].Port);
hl7listener[i].Priority = ls[i].Priority;
hl7listener[i].SiteMsgPrefix = ls[i].MsgPrefix;
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].IsBackground = true;
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}

// member variable set to false within OnStop()
while (this._serviceRunning)
{
for (i=0;i<this.threadCount;i++)
{
if (hl7listener[i].ExceptionString != "")
{
this.eventLog1.WriteEntry("Exception handled on on thread port " +
Convert.ToString(ls[i].Port) +
hl7listener[i].ExceptionString, EventLogEntryType.Error);
hl7listener[i].ExceptionString = "";
if (threadArray[i].IsAlive)
{
hl7listener[i].Stop();
threadArray[i].Abort();
threadArray[i] = null;
}
threadArray[i] = new Thread(new
ThreadStart(hl7listener[i].StartListening));
threadArray[i].Name = "HL7port"+Convert.ToString(ls[i].Port);
threadArray[i].Start();
this.eventLog1.WriteEntry("Listener thread started on port " +
Convert.ToString(ls[i].Port), EventLogEntryType.Information);
}
}

Thread.Sleep(10000);
}

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Warning: Incoming Airstrike! | last post by:
How do I set up a program inside of a windows service to run to a point and stop, to allow it to respond to events? -- Texeme Textcasting Technology http://texeme.com Indie Pop Rocks @...
2
by: Simon Niederberger | last post by:
Hi I've written a Windows Service which has - several (0-100) listeners threads which spawn worker threads based on events, timers etc - several (0-300) worker threads which handle data...
3
by: Chris Dunaway | last post by:
A quick scan of the group did not immediately reveal an answer to my questions so here goes. First let me describe my app and then I'll ask the questions. I am writing a Windows Forms App (not...
0
by: John Bown | last post by:
This query is similar to some others on this discussion group, but none of them were resolved! Can anybody help: The issue is related to integrated authentication. First I'll describe a simple...
1
by: Simon Verona | last post by:
Hope somebody can help. I have a web service written in vb.net which works fine localling on my Windows XP Pro development machine without a problem. I have deployed in onto a Windows Server...
5
by: Jason Richmeier | last post by:
The application I am currently working on contains a custom windows service. On my machine, when I logon with a domain user (non-admin) account, the user is unable to control (start and stop) the...
1
by: Mahesh Devjibhai Dhola | last post by:
Hi, Scenario: The webservice was developed on windows 2000 Pro and deployed previously on windows XP pro for testing. We have tested for many days. The client for that service was 30+ and...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.