Websocket Question

1. The problem I’m having:

Hello developer,

I’m a Caddy2 beginner and was able to successfully establish a WebSocket using an online testing tool at EasySwoole-WebSocket在线测试工具 with the testing URL at ws://test.taiwan-homecloud.work.gd

However, I encounter errors when trying to connect via my browser at http://test.taiwan-homecloud.work.gd/

Since I am not the developer of this game and am not familiar with the code, I am not sure what is causing the issue.
However, everything runs smoothly during internal network testing.
I use the external network IP direct connection is also working normally.

Thank you for your help.

2. Error messages and/or full log output:

curl -v
> GET / HTTP/1.1
> Host:
> User-Agent: curl/7.79.1
> Accept: */*
< HTTP/1.1 200 WebSocket
< Server: workerman/4.0.44
<div style="text-align:center"><h1>WebSocket</h1><hr>workerman/4.0.44</div>
2023/04/12 19:10:43.144 ERROR http.log.error dial tcp connect: connection refused {"request": {"remote_ip": "", "remote_port": "39734", "proto": "HTTP/1.1", "method": "GET", "host": "test.taiwan-homecloud.work.gd", "uri": "/", "headers": {"Accept-Language": ["en-US,en;q=0.9,de;q=0.8,fr;q=0.7,nl;q=0.6,lb;q=0.5,es;q=0.4,pt;q=0.3"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7"], "Sec-Ch-Ua-Mobile": ["?0"], "Cache-Control": ["max-age=0"], "User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36"], "Sec-Ch-Ua-Platform": [""Windows""], "Sec-Fetch-Site": ["none"], "Sec-Ch-Ua": [""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""], "Sec-Fetch-Dest": ["document"], "Accept-Encoding": ["gzip, deflate, br"], "Upgrade-Insecure-Requests": ["1"], "Connection": ["Keep-Alive"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-User": ["?1"]}}, "duration": 0.074374653, "status": 502, "err_id": "8whkrii4w", "err_trace": "reverseproxy.statusError (reverseproxy.go:1299)"}
2023/04/13 02:30:49.360 DEBUG http.handlers.reverse_proxy upstream roundtrip {"upstream": "", "duration": 0.034127878, "request": {"remote_ip": "", "remote_port": "7440", "proto": "HTTP/1.1", "method": "GET", "host": "test.taiwan-homecloud.work.gd", "uri": "/audio/music/desert.mp3", "headers": {"User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0"], "Dnt": ["1"], "Accept": ["audio/webm,audio/ogg,audio/wav,audio/*;q=0.9,application/ogg;q=0.7,video/*;q=0.6,*/*;q=0.5"], "Range": ["bytes=0-"], "Accept-Language": ["zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3"], "X-Forwarded-For": [""], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["test.taiwan-homecloud.work.gd"], "Referer": ["<mark>http://test.taiwan-homecloud.work.gd/</mark>"], "Accept-Encoding": ["identity"]}}, "headers": {"Server": ["workerman"], "Accept-Ranges": ["bytes"], "Connection": ["keep-alive"], "Content-Type": ["audio/mpeg"], "Content-Length": ["1060841"], "Last-Modified": ["Tue, 11 Apr 2023 05:14:49 GMT"]}, "status": 200}

3. Caddy version:


4. How I installed and ran Caddy:

a. System environment:

use docker

b. Command:

dockerhub download image
docker run

c. Service/unit/compose file:

I build in Synology NAS.

d. My complete Caddy config:

http://test.taiwan-homecloud.work.gd {
     @websockets {
          header Connection *Upgrade*
          header Upgrade websocket
     reverse_proxy @websockets

5. Links to relevant resources:

I think the error is pretty clear, Caddy can’t connect to your app on that port.

That’s not a problem with Caddy, really. Make sure that server is running and that your firewall(s) aren’t preventing the connection.

Thanks for your reply,
It turned out to be a server setting problem.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.