简体   繁体   English

Heroku 的 Websocket 在 chrome/firefox 上给出 404

[英]Websockets to Heroku are giving a 404 on chrome/firefox

I have my Django application deployed on heroku.我在 heroku 上部署了我的 Django 应用程序。 It uses websockets, and everything is configured properly.它使用 websockets,一切都配置正确。 When I go to my site, the websockets fail with WebSocket connection to 'wss://<url>' failed: Error during WebSocket handshake: Unexpected response code: 404 .当我将 go 连接到我的站点时,websockets 失败, WebSocket connection to 'wss://<url>' failed: Error during WebSocket handshake: Unexpected response code: 404 I did some digging and it's apparently due to chrome blocking the websockets?我做了一些挖掘,这显然是由于 chrome 阻塞了 websockets? I came across this issue which sounds like what I'm getting, but the answer did not fix it for me.我遇到了这个问题,这听起来像是我得到的,但答案并没有为我解决。

Can someone explain what's going on here, and potentially how to fix it?有人可以解释这里发生了什么,以及如何解决它吗?

So the solution was nothing to do with heroku.所以解决方案与 heroku 无关。 I was using gunicorn to deploy my application, and that does not support websockets, so when the website hit my websocket endpoint gunicorn threw back a 404. I switched to daphne, and added web: daphne <application>.asgi:application --port $PORT --bind 0.0.0.0 to the Procfile, and everything started working.我正在使用 gunicorn 部署我的应用程序,但它不支持 websockets,所以当网站点击我的 websocket 端点时,gunicorn 会返回 404。我切换到 daphne,并添加了web: daphne <application>.asgi:application --port $PORT --bind 0.0.0.0到 Procfile,一切都开始工作了。 This blog post from Heroku helped me out, most specifically This segment . 这篇来自 Heroku 的博客文章帮助了我,尤其是这个片段

try using https://<url> inspite of using wss i came across the same issue when i deployed my node.js application on heroku.尝试使用https://<url>使用wss我在 heroku 上部署我的 node.js 应用程序时遇到了同样的问题。 hope this will solve your problem too.希望这也能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM