RejectedSoftware Forums

Sign up

Always appear 502 page with message "Connection closed while writing data."

I use listenHTTPProxy() to set a layout of one front server and many back servers. After deployment, the site works fine when I visit it first time. But when I visit it again, there is a big change (yes, not always) to appear the page

502 - Bad Gateway
Connection to upstream server failed: Connection closed while writing data.

When I refresh the page, it returns normal again. The annoying 502 page always appears, and back to normal after F5.

I tried to set keepAliveTimeout larger than 10s for back servers. I also tried to set HTTPServerOption.reusePort for both front and back servers. All these guesses do not solve the problem. And sometimes I can not terminate a back server with SIGINT, SIGQUIT, SIGTERM immediately.

My front server listens port 80, my four back servers listen port 8080, 8181, 8282, 9090 respectively of 127.0.0.1. All servers reside in one droplet with Ubuntu 16.04.6 LTS.

I've no ideas what's going on. I see the message "Connection closed while writing data." is quite new, because it's in vibe-core-1.9.0 but not in vibe-core-1.8.1. Is there anyone has some ideas?

Re: Always appear 502 page with message "Connection closed while writing data."

Correct: My front server listens port 80, 443, and 80 redirect() to 443 at front server.

And I found the back server locally backed by a redis server can not terminated immediately (unless using SIGKILL). I must unsuccessfully visit the site again, then the back server was terminated, and can be restarted. It seems there is some cache mechanism there.

Re: Always appear 502 page with message "Connection closed while writing data."

Adding VibeHighEventPriority version works.

vibe-d/vibe-core#205