【问题标题】:Heroku app: Error during WebSocket handshake: Unexpected response code: 200Heroku 应用程序:WebSocket 握手期间出错:意外的响应代码:200
【发布时间】:2018-05-10 04:41:08
【问题描述】:

我遵循了一个关于如何制作多人俄罗斯方块游戏的教程,这里是 repo: https://github.com/Leftier/tetris

它在 localhost 上运行得很好,所以我尝试在 heroku 中部署它(https://tetrixtest.herokuapp.com/ --ASD 移动 Q/E 旋转)但我收到以下错误:

WebSocket connection to 'wss://tetrixtest.herokuapp.com/' failed: Error during WebSocket handshake: Unexpected response code: 200

尝试在此行中创建 webSocket(connection-manager.js 第 14 行):

this.conn = new WebSocket(`wss://${window.location.hostname}:${window.location.port}`)

我对 webSockets 了解不多, 起初我认为heroku无法处理websockets,但事实并非如此,所以我尝试直接使用链接作为参数,而不是从浏览器中读取它,但仍然是同样的问题。

我想要一些关于为什么会发生这种情况的线索/提示,我在google和github中搜索过,但我只发现了与socket.io相关的问题

【问题讨论】:

    标签: html heroku websocket


    【解决方案1】:

    对我来说,解决方案是运行这个命令heroku features:enable http-session-affinity

    更多信息https://devcenter.heroku.com/articles/session-affinity

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-22
      • 2020-01-15
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 2021-01-29
      相关资源
      最近更新 更多