# groonga - An open-source fulltext search engine and column store.

- 日本語

# 7.3.5. Request timeout

## 7.3.5.1. Summary

New in version 6.0.2.

You can set timeout to each request.

If a request isn’t completed until the specified timeout, the request is canceled. If you don’t set timeout, the request is processed until the request is completed.

Request timeout feature is useful when you implement timeout on client side. If you only implement timeout only on client side, the request keeps processing after client stops waiting response. It uses needless resources. If you set timeout to the request, the request will be canceled soon.

## 7.3.5.2. How to set timeout to request

All commands accept `request_timeout` parameter. You can set timeout to request by adding `request_timeout` parameter.

Unit of timeout out value is second. You can set timeout less than 1 second by using decimal such as `0.1`. `0.1` means 100 milliseconds.

Here is an example to set `5.5` seconds timeout to a request:

    select Users --request_timeout 5.5

## 7.3.5.3. Return code on timeout

If the request is timed out, `GRN_CANCEL` (`-77`) Return code is returned in response header.

Here is an example response on timeout:

    [
      [
        -77,
        1459846102.63304,
        0.000220775604248047,
        "[request-canceler] a request is canceled: <0x7fa0d5d7ed00>"
      ]
    ]

See Output format for response header.

## 7.3.5.4. Enable request timeout by default

groonga executable file supports enabling request timeout by default. You can specify the default request timeout by `groonga --default-request-timeout`.

If the default request timeout is larger than 0 second, the default request timeout is used as request timeout for all requests.

You can overwrite the default request timeout by specifying `request_timeout` parameter to request. If the default request timeout is 3 seconds and `request_timeout` parameter is 1 second, the request is canceled after 1 second.

## 7.3.5.5. See also

- Return code

- Output format

- request_cancel