diff --git a/ws_reverse_proxy.go b/ws_reverse_proxy.go index 90aa925..22faffe 100644 --- a/ws_reverse_proxy.go +++ b/ws_reverse_proxy.go @@ -137,9 +137,12 @@ func (w *WSReverseProxy) ServeHTTP(ctx context.Context, c *app.RequestContext) { var ce *websocket.CloseError var hzce *hzws.CloseError - if !errors.As(err, &ce) || !errors.As(err, &hzce) { + if !errors.As(err, &ce) && !errors.As(err, &hzce) { hlog.CtxErrorf(ctx, errMsg, err) + continue } + + break } }); err != nil { hlog.CtxErrorf(ctx, "can not upgrade to websocket: %v", err) diff --git a/ws_reverse_proxy_test.go b/ws_reverse_proxy_test.go index b372ea7..83fd506 100644 --- a/ws_reverse_proxy_test.go +++ b/ws_reverse_proxy_test.go @@ -55,6 +55,7 @@ func TestProxy(t *testing.T) { // proxy server ps := server.Default(server.WithHostPorts(":7777")) + ps.NoHijackConnPool = true ps.GET("/proxy", proxy.ServeHTTP) go ps.Spin() @@ -63,6 +64,7 @@ func TestProxy(t *testing.T) { go func() { // backend server bs := server.Default() + bs.NoHijackConnPool = true bs.GET("/", func(ctx context.Context, c *app.RequestContext) { // Don't upgrade if original host header isn't preserved host := string(c.Host())