XRAY: How to fix Error: “Error in Go routine: net/http: abort Handler”

Dor Tambour
2022-10-16 15:03

You might have encountered the following error from Xray router log:
 [jfrou] [ERROR] [ ] [logger.go:74 ] [main ] [] - Error in Go routine: net/http: abort Handler
[jfrou] [ERROR] [ ] [logger.go:74 ] [main ] [] - Stack: goroutine 312 [running]:

Its stacktrace looks like this:
 runtime/debug.Stack()
/root/.gvm/gos/go1.18.2/src/runtime/debug/stack.go:24 +0x68
github.com/traefik/traefik/v2/pkg/safe.defaultRecoverGoroutine({0x213f040?, 0x4000104ae0})
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/safe/routine.go:66 +0xb0
github.com/traefik/traefik/v2/pkg/safe.OperationWithRecover.func1.1()
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/safe/routine.go:74 +0x38
panic({0x213f040, 0x4000104ae0})
/root/.gvm/gos/go1.18.2/src/runtime/panic.go:838 +0x20c
net/http/httputil.(*ReverseProxy).ServeHTTP(0x40009c2550, {0x2bb82b0?, 0x400112c940}, 0x40010f0b00)
/root/.gvm/gos/go1.18.2/src/net/http/httputil/reverseproxy.go:349 +0xb8c
github.com/traefik/traefik/v2/pkg/middlewares/pipelining.(*pipelining).ServeHTTP(0x4000973bb0, {0xffff6b423f08?, 0x40009cdbf8}, 0x40010f0b00)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/pipelining/pipelining.go:36 +0xf4
github.com/traefik/traefik/v2/pkg/middlewares/accesslog.AddServiceFields({0xffff6b423f08, 0x40009cdbf8}, 0x40010f0b00, {0x2ba1608, 0x4000973bb0}, 0x4000efd300)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/accesslog/field_middleware.go:47 +0x118
github.com/traefik/traefik/v2/pkg/middlewares/accesslog.(*FieldHandler).ServeHTTP(0x40001237c0, {0xffff6b423f08, 0x40009cdbf8}, 0x36dee4?)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/accesslog/field_middleware.go:36 +0xd8
github.com/vulcand/oxy/roundrobin.(*RoundRobin).ServeHTTP(0x400056e1c0, {0xffff6b423f08, 0x40009cdbf8}, 0x40010f0a00)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/vulcand/oxy@v1.3.0/roundrobin/rr.go:147 +0x460
github.com/traefik/traefik/v2/pkg/middlewares/emptybackendhandler.(*emptyBackend).ServeHTTP(0x4000973f10, {0xffff6b423f08, 0x40009cdbf8}, 0x205a4a0?)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/emptybackendhandler/empty_backend_handler.go:25 +0x10c
github.com/traefik/traefik/v2/pkg/middlewares/tracing.(*forwarderMiddleware).ServeHTTP(0x4000e89560, {0xffff6b36fe40?, 0x40009cdbf0}, 0x40010f0900)
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/tracing/forwarder.go:56 +0x354
github.com/traefik/traefik/v2/pkg/middlewares/retry.(*retry).ServeHTTP.func1()
/root/.gvm/pkgsets/go1.18.2/global/pkg/mod/github.com/traefik/traefik/v2@v2.6.3/pkg/middlewares/retry/retry.go:101 +0x454

This Error is caused by Artifactory third-party proxy service called Traefik which had a bug in the retrying process of the middleware-proxy.This can be seen in the stacktrace.

If you see the error you can disable Artifactory’s router retrying process by adding the following to Artifactory system.yaml:
 router:
retry:
enabled: false

or: export JF_ROUTER_RETRY_ENABLED=false in OS environment

And then restart Artifactory to apply changes.