Heroku上可以实现类似websocket的行为? [英] Realtime websocket-like behavior possible on Heroku?

查看:195
本文介绍了Heroku上可以实现类似websocket的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在Rails中制作一个国际象棋应用程序,这些应用程序需要异步地从服务器推送到客户端浏览器(理想情况下使用websockets)。

然而,我做了什么小研究似乎表明Heroku不支持websocket。但是,在使用配置为使用长轮询而不是websocket的socket.io方面还有一个选择。



长时间轮询不足以实现类似5分钟突击游戏的延迟要求Heroku Cedar堆栈支持HTTP Streaming和长轮询:

解决方案

https://devcenter.heroku.com/articles/request-timeout#longpolling_and_streaming_responses



它不支持WebSockets。但您可以使用 Faye 等框架,并使用XHR作为传输机制。看来这是一个项目。请参阅:
可以在Heroku上主持FAYE吗?



如果您想在您的游戏客户端中使用WebSocket并在Heroku上使用后端,那么我现在唯一知道的解决方案是使用Pusher (我为插件工作的人):
https://addons.heroku.com/pusher


I am considering making a chess app in Rails where moves need to be pushed from the server to the client browser asynchronously (ideally with websockets).

However, from what little research I've done it appears that Heroku does not support websockets. But there is an alternative in using socket.io configured to use long polling instead of websockets.

Is long polling insufficient to achieve latency requirements for something like a 5 minute blitz game of chess?

解决方案

The Heroku Cedar stack supports HTTP Streaming and Long Polling: https://devcenter.heroku.com/articles/request-timeout#longpolling_and_streaming_responses

It doesn't support WebSockets. But you can use a framework like Faye and use XHR as the transport mechanism. It seems there's a project for this. See: Is it possible to host FAYE, on Heroku?

If you want to use WebSocket in your game client and have your backend on Heroku then the only solution that I know of right now is to use the Pusher (who I work for addon): https://addons.heroku.com/pusher

这篇关于Heroku上可以实现类似websocket的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆