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

Problem:

CodeTwo services cannot be started or stopped.

Solution:

In some environments, applications installed as Windows services may require more time to start or stop. Click on the links below to learn how to change the timeout for service applications in Windows.

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

To avoid the service startup problem (Fig. 1.), you can:

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

How to delay the automatic start of a service application

If a service's start is delayed, this service attempts to start only if critical system services have already started. To configure your service this way, you need to:

  1. Run Windows Services manager (launch services.msc from the Start menu).
  2. Right-click on the service you would like to configure, and select Properties.
  3. On the General tab, change the Startup type to Automatic (Delayed Start), as shown in Fig. 2. for CodeTwo Exchange Sync.

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

How to increase the timeout value for the service startup

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

  1. Launch Windows Registry Editor.
  2. Find the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
  3. Right-click this key and select NewDWORD (32-bit) Value.
  4. A new value named New Value #1 appears on the right.
  5. Change the name of this new value to ServicesPipeTimeout.
  6. Right-click the ServicesPipeTimeout value you created, and choose Modify. The Edit DWORD Value window opens.
  7. Change Base to Decimal.
  8. In the Value data field, type the value (in milliseconds) of time allowed for the service to start, and click OK.

    Info

    In our test environment, we set the value (Fig. 3.) to 240000 ms (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.

    228-3
    Fig. 3. Setting a new timeout value.

  9. Finally, restart the machine.

A CodeTwo service does not stop

If the problem happens for the first time and you are not able to close the service from within Windows Services manager (services.msc) or Task Manager, you can kill the service using the taskkill command. See this Knowledge Base article for details.

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

  1. Launch Windows Registry Editor.
  2. Locate this registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
  3. Right-click this key and choose New > DWORD (32-bit) Value.
  4. A new value named New Value #1 appears in the right pane.
  5. Rename the new value to WaitToKillServiceTimeout.
  6. Right-click the value and select Modify. The Edit DWORD Value window pops up.
  7. Change Base to Decimal.
  8. In the Value data field, type the value (in milliseconds) of time allowed for the service to stop, and confirm by clicking OK.

    Info

    By default, Windows waits 20000 ms, so you might need to set a higher value.

  9. Finally, restart your machine.

See also: