-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Current Behavior
apisix: apache/apisix:2.15.0-alpine
plugin-runner: apache/apisix-go-plugin-runner v0.4.0
run apisix-go-plugin-runner ,in func RequestFilter, WriteHeader then return, grpc client will report an error(code = Internal desc = server closed the stream without sending trailers)
I studied for a day and didn't know how to solve the problem. can anybody help solve the problem? thanks a lot!
Expected Behavior
grpc client not report error,and can get trailers
Error Logs
rpc error: code = Internal desc = server closed the stream without sending trailers
Steps to Reproduce
apisix: apache/apisix:2.15.0-alpine
plugin-runner: apache/apisix-go-plugin-runner v0.4.0
- modify code in apisix-go-plugin-runner-master\cmd\go-runner\plugins\say.go, as follows:
func (p *Say) RequestFilter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
w.Header().Set("Content-Type", r.Header().Get("Content-Type"))
num := rand.Int()
if num%2 == 1 {
w.WriteHeader(http.StatusOK)
w.Header().Set("mykey", "test")
w.Header().Set("Grpc-Status", "0")
w.Header().Set("Grpc-Message", "ok")
w.Header().Set("Grpc-Status-Details-Bin", "")
return
}
}
run a grpc server in 192.168.56.19:8301
2. then run apisix, config upstream in APISIX Dashboard,as follows:
{
"nodes": [
{
"host": "192.168.56.19",
"port": 8301,
"weight": 1
}
],
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "roundrobin",
"scheme": "grpc",
"pass_host": "pass",
"name": "testa",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
}
}
- then add a route config, as follows:
{
"uri": "/routeguide.RouteGuide/GetFeature",
"name": "testa1",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"plugins": {
"ext-plugin-post-req": {
"conf": [
{
"name": "say",
"value": "{\"body\":\"123\"}"
}
],
"disable": false
}
},
"upstream_id": "425744995673178819",
"status": 1
}
- then use client grpc call apisix, but have an error (rpc error: code = Internal desc = server closed the stream without sending trailers),as follows:
2022/09/21 19:45:47.860 [I] [main.go:59] header: map[content-type:[application/grpc] date:[Wed, 21 Sep 2022 11:45:47 GMT] mykey:[test] server:[APISIX/2.15.0]]
2022/09/21 19:45:47.860 [I] [main.go:60] trailer: map[]
2022/09/21 19:45:47.861 [E] [main.go:62] rpc error: code = Internal desc = server closed the stream without sending trailers
Environment
os: win10
apisix: apache/apisix:2.15.0-alpine (use apisix-docker\example\docker-compose.yml docker-compose up)
plugin-runner: apache/apisix-go-plugin-runner v0.4.0