4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WebSocket(ws://)の接続がうまくいかない時に試すこと

Posted at

#結論
SSL証明書使ってwss://にすればたいていうまくいく

#なんでよ
どっか(ex. proxyとか)がレスポンスのConnectionヘッダを上書きしてしまうため
Upgradeができないことが大抵の原因だったりします(実体験)

WebSocketのHandshake時、レスポンスヘッダが

Connection: upgrade
Upgrade: WebSocket

とならないといけないのに

Connection: keep-alive
Upgrade: WebSocket

となってしまい、Upgradeができないことが原因です。
Proxyを経由する接続の場合に多い現象です。

wssにすることでConnectionヘッダーの上書きが抑止されることが多いため
まずは接続できないという人は試してみると幸せになれるかもしれません。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?