Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

压力测试时并发量达到一个临界值时会出现丢失请求头的情况:missing token in header #1266

Closed
jredream opened this issue Jan 21, 2025 · 1 comment

Comments

@jredream
Copy link

Describe the Question

压力测试时并发量达到一个临界值时会出现丢失请求头的情况:missing token in header

Reproducible Code

hertz config

h := server.New(
		server.WithHostPorts(address),
		server.WithReadTimeout(60*time.Second),
		server.WithWriteTimeout(60*time.Second),
	)

paseto config

func InitOauth2Paseto() app.HandlerFunc {
	parseFunc := encryptFunc()
	return paseto.New(
		paseto.WithParseFunc(parseFunc),
		paseto.WithTokenPrefix("Bearer "),
		paseto.WithSuccessHandler(func(ctx context.Context, c *app.RequestContext, token *paseto2.Token) {
			c.Set(global.PasetoCxtUserKey, token.Claims())
		}),
		paseto.WithErrorFunc(func(ctx context.Context, c *app.RequestContext) {	
                        hlog.CtxErrorf(ctx,"%s Token异常: %+v", c.FullPath(), c.Errors[0])
			hlog.CtxErrorf(ctx,"%s Authorization: %s", c.FullPath(), string(c.GetHeader("Authorization")))	
			c.AbortWithStatusJSON(403, ResponseEntity[any]{
				Status:  403,
				Message: fmt.Sprintf("Token异常: %v", c.Errors[0]),
			})
		}),
	)
}

Expected behavior

即使高并发请求也不丢失请求头

Screenshots

Image

Hertz version:

github.com/cloudwego/hertz v0.9.2
aidanwoods.dev/go-paseto v1.3.0
github.com/hertz-contrib/paseto v0.0.0-20230508023022-71af6635a26c

Environment:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/xxx/Library/Caches/go-build'
GOENV='/Users/xxx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/xxx/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/xxx/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/xxx/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yc/hyb7m3f13blbv4shhvxrrw0h0000gn/T/go-build2710603239=/tmp/go-build -gno-record-gcc-switches -fno-common'

Additional context

@xiaost
Copy link
Contributor

xiaost commented Jan 22, 2025

你提供的并不是复现问题的代码。请提供能复现问题的代码,另外复现代码请去掉所有第三方库的依赖,包括 aidanwoods.dev/go-paseto, hertz-contrib/paseto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants