You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The HTTP request context is not propagated to the proxy level, which leads not to getting an HTTP cancel signal into the client plugin as well as any stored context values from the handler plugins.
To Reproduce
Steps to reproduce the behavior:
Create a client plugin with the following the handler
func registerClients(ctx context.Context, extra map[string]interface{}) (http.Handler, error) {
return http.HandlerFunc(
func(w http.ResponseWriter, req *http.Request) {
select {
case <-req.Context().Done():
fmt.Println("cancel signal received")
return
case <-time.After(10 * time.Second):
fmt.Println("timeout")
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte("{}"))
}), nil
}
$ go run ./cmd/krakend-ce/main.go run -c krakend.json
curl to the endpoint with a short timeout
$ curl -m 2 -v http://localhost:8080/test
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /test HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.79.1
> Accept: */*
>
* Operation timed out after 2004 milliseconds with 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 2004 milliseconds with 0 bytes received
Expected behavior
expect to get the context.Done to be sent by the request cancelation from the client side and see the log of cancel signal received
Logs
Parsing configuration file: krakend.json
[KRAKEND] 2022/07/15 - 11:11:35.036 ▶ DEBUG [SERVICE: Plugin Loader] Starting loading process
RegisterLogger called with: gologging.Logger{logger:(*logging.Logger)(0x14000a83ef0)}
[KRAKEND] 2022/07/15 - 11:11:35.053 ▶ INFO [SERVICE: Executor Plugin] Total plugins loaded: 1
[KRAKEND] 2022/07/15 - 11:11:35.053 ▶ DEBUG [SERVICE: Handler Plugin] plugin
[KRAKEND] 2022/07/15 - 11:11:35.053 ▶ DEBUG [SERVICE: Modifier Plugin] plugin
[KRAKEND] 2022/07/15 - 11:11:35.053 ▶ DEBUG [SERVICE: Plugin Loader] Loading process completed
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ INFO Starting the KrakenD instance
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ DEBUG [ENDPOINT: /test] Building the proxy pipe
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ DEBUG [BACKEND: /] Building the backend pipe
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ DEBUG [BACKEND: /] Injecting plugin client-plugin
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ DEBUG [ENDPOINT: /test] Building the http handler
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ DEBUG [ENDPOINT: /test][JWTSigner] Signer disabled
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ INFO [ENDPOINT: /test][JWTValidator] Validator disabled for this endpoint
[KRAKEND] 2022/07/15 - 11:11:35.054 ▶ INFO [SERVICE: Gin] Listening on port: 8080
[KRAKEND] 2022/07/15 - 11:11:40.037 ▶ DEBUG [SERVICE: Telemetry] Registering usage stats for Cluster ID
timeout
[GIN] 2022/07/15 - 11:11:52 | 200 | 10.004338666s | 127.0.0.1 | GET "/test"
Additional context
Add any other context about the problem here.
gin.Context does not gets the request cancel signal, therefore Request.Context() inside of the gin.Context should be handed over to propagate the cancel signal and its stored values.
This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.
Describe the bug
The HTTP request context is not propagated to the proxy level, which leads not to getting an HTTP cancel signal into the client plugin as well as any stored context values from the handler plugins.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
expect to get the context.Done to be sent by the request cancelation from the client side and see the log of
cancel signal received
Logs
Additional context
Add any other context about the problem here.
gin.Context does not gets the request cancel signal, therefore Request.Context() inside of the gin.Context should be handed over to propagate the cancel signal and its stored values.
requestCtx, cancel := context.WithTimeout(c.Request.Context(), configuration.Timeout)
code reference
The text was updated successfully, but these errors were encountered: