CodeTwo Base.title

How to extend the timeout for services if they fail to start or stop

Problem:

CodeTwo services either do not start or do not stop.

Solution:

In some environments the services may require more time to start or stop. Click one of the problems below to find the solution.

A CodeTwo service is unable to start on its own and times out

228-0
Fig. 1. CodeTwo service does not start and times out.

To avoid such problems, you can set an option to delay the automatic start of a service. The service with such configuration will attempt to start only if critical services have already started. In order to configure your service this way, please follow the steps described below:

  1. Run services.msc.
  2. Right-click on the service you would like to configure.
  3. Select Properties from the context menu.
  4. On the General tab, switch the Startup type to Automatic (Delayed Start).

228-2
Fig. 2. Selecting the startup type of a service.

Additionally, you can extend the timeout value for the service startup in the Windows registry:

  1. In Registry Editor, locate, and then right-click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
  2. Point to New and click DWORD Value.
  3. In the right pane of Registry Editor a new value named New Value #1 will appear.
  4. Type ServicesPipeTimeout to rename New Value #1, and then press ENTER.
  5. Right-click the ServicesPipeTimeout registry entry that you created and choose Modify. The Edit DWORD Value dialog box will appear.
  6. Change Base to Decimal.
  7. In the Value data text box, type <TimeoutPeriod>, where TimeoutPeriod is the amount of time allowed for the service to start (in milliseconds), and then click OK.
  8. Finally, restart the machine.

In our test environment the value was set to 240.000ms (4 minutes) and this enabled the service to start correctly. It is permissible to set a higher value - it should not have any impact on performance.

A CodeTwo service hangs on stopping

If the problem happens for the first time and you cannot close the service from within Windows Services Menu (services.msc) or Task Manager, you can kill the service using the taskkill command. Please see this Knowledge Base article for details.

If the problem occurs frequently, follow the steps below to extend the service closing timeout:

  1. In Registry Editor, locate, and then right-click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
  2. Point to New and click DWORD Value.
  3. In the right pane of Registry Editor a new value named New Value #1 will appear.
  4. Type WaitToKillServiceTimeout to rename New Value #1, and then press ENTER.
  5. Right-click the WaitToKillServiceTimeout registry entry that you created and choose Modify.The Edit DWORD Value dialog box will appear.
  6. Change Base to Decimal.
  7. In the Value data text box, type <TimeoutPeriod>, where TimeoutPeriod is the amount of time allowed for the service to stop (in milliseconds), and then click OK.
  8. Finally, restart the machine.

As described in this MS KB article, by default Windows waits 20.000ms, so you might need to increase this value.

See also:

Our Clients:
Unicef
Facebook
Shell
T-Systems
Loreal
Casio
UPS Israel
Oford University
Mitsubishi Motors
Toshiba TEC UK Imaging Systems Ltd
Illinois Institute of Technology
MAN Diesel
McDonalds India
Skoda Auto
Bank of Israel
Fujifilm
China Mobile
Santander
Samsung SDI
Skanska
Generali
Telmex
Toyota Tsusho
BECHTEL
Ricoh
BAE SYSTEMS
Federação Portuguesa de Futebol
Credit Agricole
HYUNDAI
Rothschild
Toyota Boshoku
Oriflame Romania
ING
Ikea
Nordea

Partners, certificates & awards