Problem in running .Net Service on a Quad Processor


S

sunil

Dear All,
I have created a .Net service in 2.0 and running it on a machine that
has a Quad Processor.
It is failing with the following error.
"Error 1053: The service did not respond to the start or control
request in a timely fashion"
This is what I saw in event Viewer.
Timeout (30000 milliseconds) waiting for the MyService Server service
to connect.

The following is the System Information of my server
OS Name Microsoft(R) Windows(R) Server 2003, Standard Edition
Version 5.2.3790 Service Pack 1 Build 3790
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name TEST_SRV
System Manufacturer IBM
System Model IBM x3850-[88631RA]-
System Type X86-based PC
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
Processor x86 Family 15 Model 4 Stepping 9 GenuineIntel ~3169 Mhz
BIOS Version/Date IBM -[ZUE154BUS-1.09]-, 6/15/2006

Is this due to compilation problem? Please help.

Thanks & regards
Sunil
 
Ad

Advertisements

W

Willy Denoyette [MVP]

Dear All,
I have created a .Net service in 2.0 and running it on a machine that
has a Quad Processor.
It is failing with the following error.
"Error 1053: The service did not respond to the start or control
request in a timely fashion"
This is what I saw in event Viewer.
Timeout (30000 milliseconds) waiting for the MyService Server service
to connect.

This is because your OnStart method did not return in a timely fashion, once the Onstart is
called the SCM waits for a maximum of 30 seconds for it to return, if OnStart doesn't return
within this 30 secs., then the SCM considers the service has failed to start, logs a message
and kill the service.
So, you have to investigate your OnStart and try to find out why it takes longer than 30
seconds to return.

Willy.
 
S

sunil

Thanks Willy,
But what baffles me is that on my machine it does not give this timeout
This is my system configuration:
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
OS Manufacturer Microsoft Corporation
System Name USER_XP
System Manufacturer Dell Inc.
System Model OptiPlex GX620
System Type X86-based PC
Processor x86 Family 15 Model 6 Stepping 4 GenuineIntel ~3391 Mhz
Processor x86 Family 15 Model 6 Stepping 4 GenuineIntel ~3391 Mhz
BIOS Version/Date Dell Inc. A07, 31/03/2006
SMBIOS Version 2.3
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "5.1.2600.2180
(xpsp_sp2_rtm.040803-2158)"
Total Physical Memory 2,048.00 MB
Available Physical Memory 1.52 GB
Total Virtual Memory 2.00 GB
Available Virtual Memory 1.96 GB
Page File Space 3.85 GB
Page File C:\pagefile.sys

Is this something got to also do with OS? In fact shouldn't my service
be faster on a QuadProc machine?
Also when I compiled the service and debugmode it ran on the
QuadProcessor machine without any errors.
I need to answer these questions before I advice my peers any changes.
Please help.

Thanks a lot.

Many regards
Sunil
 
J

John J. Hughes II

I would have a tendency to say it was something else that is different on
the two machines then the number of processor. Does you service log event
as to it state, how far is it getting? If you comment out your code so the
service starts but does nothing do you still get the error?

Regards,
John
 
W

Willy Denoyette [MVP]

Thanks Willy,
But what baffles me is that on my machine it does not give this timeout

Forget about the hw configuration and concentrate on the OnStart method, there is something
preventing it to return in a timely fashion? It's impossible for us to tell you what's
happening without seeing any code, so please show us at least how your OnStart looks like.

Willy.
 
S

sunil

Hi Willy,
The following is the code snippet that my Service Executes onStart
public static void Start( bool isConsole, string[] args )
{
try
{
AppDomain curr = AppDomain.CurrentDomain;
AppDomainSetup info = new AppDomainSetup();

info.ApplicationBase = curr.BaseDirectory;
info.ApplicationName = typeof( ServiceRuntime ).FullName;
info.ApplicationBase = curr.BaseDirectory;
info.ConfigurationFile =
curr.SetupInformation.ConfigurationFile.Replace( ".CmdLine.", "." );
info.ShadowCopyFiles = "false";

_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );
}
catch( Exception e )
{
throw;
}
}

In _Start I am creating a few threads...
for( int i = 0; i < nThreads; i++ )
{
t = new Thread ( new ThreadStart ( this.ThreadProc ) ) ;
t.Name = "Job Processor Engine Thread(" + i.ToString() + ")";
t.Start () ;
this.threads.Add ( t ) ;
}
and doing some db activites....
But why is this failing on a QuadProc machine and working well on other
machines? Is there some setting I need to tune/change? Please help...

Thanks & regards
Sunil
 
Ad

Advertisements

W

Willy Denoyette [MVP]

Hi Willy,
The following is the code snippet that my Service Executes onStart
public static void Start( bool isConsole, string[] args )
{
try
{
AppDomain curr = AppDomain.CurrentDomain;
AppDomainSetup info = new AppDomainSetup();

info.ApplicationBase = curr.BaseDirectory;
info.ApplicationName = typeof( ServiceRuntime ).FullName;
info.ApplicationBase = curr.BaseDirectory;
info.ConfigurationFile =
curr.SetupInformation.ConfigurationFile.Replace( ".CmdLine.", "." );
info.ShadowCopyFiles = "false";

_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );
}
catch( Exception e )
{
throw;
}
}

In _Start I am creating a few threads...
for( int i = 0; i < nThreads; i++ )
{
t = new Thread ( new ThreadStart ( this.ThreadProc ) ) ;
t.Name = "Job Processor Engine Thread(" + i.ToString() + ")";
t.Start () ;
this.threads.Add ( t ) ;
}
and doing some db activites....
But why is this failing on a QuadProc machine and working well on other
machines? Is there some setting I need to tune/change? Please help...

Thanks & regards
Sunil

Well I can't tell, first I asked to post your "OnStart()" code, instead you post Start, it's
not clear at all how you call this from OnStart().
It looks like you don't run this "Start" in another thread, that means that OnStart only
returns to the SCM when Start returns. Now, if you DB activity takes more than 30 seconds
(possibly a connection cannot be made because your connection parameters aren't valid or the
security context is invalid etc...), the SCM will get nervous and kill the "OnStart" thread
and bail out. Keep in mind that OnStart runs on an SCM thread not on a CLR thread, the SCM
is the master of the game here, you have to obey his rules ;-)
So, I would suggest you run this "Start" method on a separate background thread from OnStart
and return from OnStart when the thread has started. Also, you should code more defensively,
You should add tracing and logging to your methods, your exception handling should also
largely be improved.

Willy.
 
S

sunil

Hi Willy,
The OnStart method calls the Start method. I had actually left out the
exception handling as it was not needed to be posted...:) well I did a
trace of the application and found that the maximum time taken was for
just invoking the _init & the _Start method...
_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );

After the AppDomain is created and the call to _init takes more than
40sec...I put a trace statement before the function call, in the first
line of the function and at end of the function...
00000007 11.30131397 [2864] JOBServer: Init Call
00000382 41.83827053 [2864] JOBServer: Init Function Start
00001228 71.89844367 [2864] JOBServer: Init Function end
00001229 71.89849695 [2864] JOBServer: Init invoked successfully
00001242 101.93207238 [2864] JOBServer: Begin of ServiceRuntime _Start

00001284 103.17994353 [2864] JOBServer: End of ServiceRuntime _Start
Why is calling an AppDomain function taking such a long time? Is there
some CAS done? It is fast on my Windows XP machine.
Any clues?

Thanks & regards
Sunil
Hi Willy,
The following is the code snippet that my Service Executes onStart
public static void Start( bool isConsole, string[] args )
{
try
{
AppDomain curr = AppDomain.CurrentDomain;
AppDomainSetup info = new AppDomainSetup();

info.ApplicationBase = curr.BaseDirectory;
info.ApplicationName = typeof( ServiceRuntime ).FullName;
info.ApplicationBase = curr.BaseDirectory;
info.ConfigurationFile =
curr.SetupInformation.ConfigurationFile.Replace( ".CmdLine.", "." );
info.ShadowCopyFiles = "false";

_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );
}
catch( Exception e )
{
throw;
}
}

In _Start I am creating a few threads...
for( int i = 0; i < nThreads; i++ )
{
t = new Thread ( new ThreadStart ( this.ThreadProc ) ) ;
t.Name = "Job Processor Engine Thread(" + i.ToString() + ")";
t.Start () ;
this.threads.Add ( t ) ;
}
and doing some db activites....
But why is this failing on a QuadProc machine and working well on other
machines? Is there some setting I need to tune/change? Please help...

Thanks & regards
Sunil

Well I can't tell, first I asked to post your "OnStart()" code, instead you post Start, it's
not clear at all how you call this from OnStart().
It looks like you don't run this "Start" in another thread, that means that OnStart only
returns to the SCM when Start returns. Now, if you DB activity takes more than 30 seconds
(possibly a connection cannot be made because your connection parameters aren't valid or the
security context is invalid etc...), the SCM will get nervous and kill the "OnStart" thread
and bail out. Keep in mind that OnStart runs on an SCM thread not on a CLR thread, the SCM
is the master of the game here, you have to obey his rules ;-)
So, I would suggest you run this "Start" method on a separate background thread from OnStart
and return from OnStart when the thread has started. Also, you should code more defensively,
You should add tracing and logging to your methods, your exception handling should also
largely be improved.

Willy.
 
W

Willy Denoyette [MVP]

Hi Willy,
The OnStart method calls the Start method. I had actually left out the
exception handling as it was not needed to be posted...:) well I did a
trace of the application and found that the maximum time taken was for
just invoking the _init & the _Start method...
_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );

After the AppDomain is created and the call to _init takes more than
40sec...I put a trace statement before the function call, in the first
line of the function and at end of the function...
00000007 11.30131397 [2864] JOBServer: Init Call
00000382 41.83827053 [2864] JOBServer: Init Function Start
00001228 71.89844367 [2864] JOBServer: Init Function end
00001229 71.89849695 [2864] JOBServer: Init invoked successfully
00001242 101.93207238 [2864] JOBServer: Begin of ServiceRuntime _Start

00001284 103.17994353 [2864] JOBServer: End of ServiceRuntime _Start
Why is calling an AppDomain function taking such a long time? Is there
some CAS done? It is fast on my Windows XP machine.
Any clues?

I can't answer this, guess you're dealing with some time-out situation, what framework and
OS are you running this on?
Again, don't do all this in the OnStart method, simply create a new thread and run your
Start in this thread, once this thread is started return from OnStart. This way you make the
SCM happy and you run your code on a thread that's not entered from unmanaged code.

Willy.
 
S

sunil

Hi Willy,
Finally I could find a solution to this problem...this seems to be
related to Windows2003 Server sp1...
I set the value of the registry value 'State' under the following
registry key as '23e00'.
KEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust
Providers\Software Publishing
and my Service started within a few seconds...no code changes done..I
guess this is something to do with digital signature/ security...Can
someone throw some light on this issue?

Thanks & regards
Sunil
Hi Willy,
The OnStart method calls the Start method. I had actually left out the
exception handling as it was not needed to be posted...:) well I did a
trace of the application and found that the maximum time taken was for
just invoking the _init & the _Start method...
_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);

_runtime.Init( isConsole );
_runtime._Start( args );

After the AppDomain is created and the call to _init takes more than
40sec...I put a trace statement before the function call, in the first
line of the function and at end of the function...
00000007 11.30131397 [2864] JOBServer: Init Call
00000382 41.83827053 [2864] JOBServer: Init Function Start
00001228 71.89844367 [2864] JOBServer: Init Function end
00001229 71.89849695 [2864] JOBServer: Init invoked successfully
00001242 101.93207238 [2864] JOBServer: Begin of ServiceRuntime _Start

00001284 103.17994353 [2864] JOBServer: End of ServiceRuntime _Start
Why is calling an AppDomain function taking such a long time? Is there
some CAS done? It is fast on my Windows XP machine.
Any clues?

I can't answer this, guess you're dealing with some time-out situation, what framework and
OS are you running this on?
Again, don't do all this in the OnStart method, simply create a new thread and run your
Start in this thread, once this thread is started return from OnStart. This way you make the
SCM happy and you run your code on a thread that's not entered from unmanaged code.

Willy.
 
W

Willy Denoyette [MVP]

Hi Willy,
Finally I could find a solution to this problem...this seems to be
related to Windows2003 Server sp1...
I set the value of the registry value 'State' under the following
registry key as '23e00'.
KEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust
Providers\Software Publishing
and my Service started within a few seconds...no code changes done..I
guess this is something to do with digital signature/ security...Can
someone throw some light on this issue?

Are you running/loading Certificate assigned assemblies? If this is true (I wonder why), you
need to make sure you have an internet connection. This because the CLR will try to download
the CRL (Certificate Revocation List) while checking the signature. By tweaking the registry
you did disable the download of CRL's for the whole system.

Willy.
 
Ad

Advertisements

S

sunil

Hi Willy,
Yes, I am loadin a signed assembly...could you suggest recommend
possible solutions...I found a couple of them
1. A simple solution to the CRL check overhead is to use authenticode
certificates that don't have a CDP embedded in them. Of course, this
generally implies a self-signed cert, Is this an acceptable compromise?
2. Write a thin native layer which is the signed entry point, and
delegates to managed code to do the rest of the work as another option.


What do you suggest?

Thanks & regards
Sunil
 

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

Similar Threads


Top