Why won't my app establish websocket connection on Heroku?

后端 未结 1 1386
一整个雨季
一整个雨季 2021-01-17 18:55

I am trying to deploy my nodejs app on heroku. I cannot get the websocket connection to establish. I have read everything I could find, tried every example and none of them

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 19:11

    Well I figured it out. Here is what you should know:

    • I did not change my server configurations from my original post.

    My client configurations looked like this:

    var host = location.origin.replace(/^http/, 'ws');
    this.connection = new WebSocket(host);
    

    But here is the kicker. On the terminal I used the following command:

    heroku labs:enable websockets
    

    And voila, it works! I hope this helps someone.

    0 讨论(0)
提交回复
热议问题