blog.est.im

不修改nginx接收websocket (opens in new tab)

以前只记得要支持websocket 需要 nginx 改: location /ws-service-a { proxy_pass proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } 今天折腾忘记这茬了,一直在调 FastAPI ,@app.websocket() 死活不识别 wscat 的请求 WebSocket 协议的工作方式是: 1.客户端发 GET + Upgrade: websocket 头 2.服务端识别这个特殊 GET,返回 101 Switching Protocols 3.连接升级完成 opus-4.6 说:既然路由确实注册了,那问题几乎可以确定是:前面的反向代理/LB 没有透传 WebSocket 我就来劲了,让AI写一份 特殊 GET,返回 101 Switching Protocols 。 结果还真成功了。wscat 返回 error: Invalid Sec-WebSocket-...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help