Skip to content

Commit

Permalink
docs: Timeouts in CTP
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Feb 27, 2024
1 parent f316c69 commit e71e880
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions site/content/en/latest/user/client-traffic-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,58 @@ Handling connection for 8888
}
```
### Enable HTTP request timeout
This example configures the HTTP request timeout for the client, please check out the details [here](https://www.envoyproxy.io/docs/envoy/latest/faq/configuration/timeouts#stream-timeouts).
```shell
cat <<EOF | kubectl apply -f -
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: client-timeout
spec:
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
name: eg
timeout:
http:
requestReceivedTimeout: 2s
EOF
```
Curl the example app through Envoy proxy:
```shell
curl -v http://$GATEWAY_HOST/get \
-H "Host: www.example.com" \
-H "Content-Length: 10000"
```
You should expect `428` response status after 2s:
```shell
curl -v http://$GATEWAY_HOST/get \
-H "Host: www.example.com" \
-H "Content-Length: 10000"
* Trying 172.18.255.200:80...
* Connected to 172.18.255.200 (172.18.255.200) port 80
> GET /get HTTP/1.1
> Host: www.example.com
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Length: 10000
>
< HTTP/1.1 408 Request Timeout
< content-length: 15
< content-type: text/plain
< date: Tue, 27 Feb 2024 07:38:27 GMT
< connection: close
<
* Closing connection
request timeout
```
[ClientTrafficPolicy]: ../../api/extension_types#clienttrafficpolicy
[BackendTrafficPolicy]: ../../api/extension_types#backendtrafficpolicy

0 comments on commit e71e880

Please sign in to comment.