Caddy: WebSocket proxy does not close connection when remote shutdown

Created on 26 Aug 2017  路  3Comments  路  Source: caddyserver/caddy

1. What version of Caddy are you using (caddy -version)?

amd64 0.10.7 downloaded from GitHub release

2. What are you trying to do?

I have two caddy servers (simulating my production setup):

  • One serving as the reverse proxy to the backend
  • The backend serve a websocket connection

When I SIGINT the backend caddy, the websocket connection still remain connected until I try to send something.

3. What is your entire Caddyfile?

Frontend:

:2015
proxy / http://localhost:9999 {
    websocket
    transparent
}
log stdout

Backend:

:9999

websocket / "cat /dev/urandom"
log stdout

4. How did you run Caddy (give the full command and describe the execution environment)?

./caddy. Tested on up-to-date Arch Linux as of this time of filing.

5. Please paste any relevant HTTP request(s) here.

I tested by running wscat -c ws://localhost:2015 and ctrl+c the backend server. wscat version 1.0.1.

6. What did you expect to see?

The connection should be terminated immediately when the backend server shutdown.

7. What did you see instead (give full error messages and/or log)?

The connection get terminated only if I press enter (send a message) in wscat.

8. How can someone who is starting from scratch reproduce the bug as minimally as possible?

I believe the setup above is already simple to setup.

bug

All 3 comments

Thanks for filing this issue! Finally had a chance to look into this tonight, and your report checks out.

Thanks to @tw4452852 , this should be fixed now. If you can build from source, feel free to test it out!

Can confirm, the problem was fixed in master.

Was this page helpful?
0 / 5 - 0 ratings