dszdiavv474681
2012-07-04 19:07
浏览 197
已采纳

在Apache服务器上使用WebSocket

With all the buzz around WebSockets, it's pretty hard to find a good walkthrough on how to use them with an Apache server on Google.

We're developing a plugin, in PHP (symfony2), which will run from time to time kind of a chat instance. And we find WebSockets more interesting, standard and quick than AJAX for this matter. The thing is, we don't have much sysadmin ressources in our group and we find hard to gather good informations on the following matters:

  • Can we run a WebSocket instance on a traditional Apache, dedicated server, and if yes, do you have useful links for us?
  • If we need to mod the server, what kind of tools would you recommend knowing that we are not too skilled in sysadmin so we can't afford to have a high maintenance b*** on this.

Thank you very much,

ps: we'll link back to your blog/site as we'll make a technical/informational post on our devblog about this part of our app.

Thank you again!

图片转代码服务由CSDN问答提供 功能建议

围绕WebSockets的所有讨论,很难找到关于如何在Apache服务器上使用它们的一个很好的演练 在Google上。

我们正在开发一个PHP(symfony2)插件,它将不时运行一种聊天实例。 我们发现WebSockets在这方面比AJAX更有趣,更标准,更快捷。 问题是,我们的组中没有太多sysadmin资源,我们发现很难收集有关以下事项的良好信息:

  • 我们可以运行WebSocket实例吗? 在传统的Apache,专用服务器上,如果是的话,你有没有为我们提供有用的链接?
  • 如果我们需要修改服务器,你会推荐哪种工具知道我们不是 熟练掌握系统管理员,所以我们无法承担高维护费用。

    非常感谢, \ n

    ps:我们将链接回您的博客/网站,因为我们将在我们的devblog上发布有关我们应用程序这一部分的技术/信息性帖子。

    再次感谢您 !

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • douzhong8856 2012-07-04 19:19
    已采纳

    One path is to use an independent installed web sockets server.

    For PHP you can try: http://code.google.com/p/phpwebsocket/ or http://github.com/Devristo/phpws/

    There are some other projects which you can try as well.

    Basically, you need to upload, unpack and start running the process.

    On the frontend, you'll have javascript connecting to the server on the specific port.

    Most websocket servers have a demo which echoes back whatever it hears, so this is a good place to write some test code. You may even find a rudimentary chat implementation.

    The tricky part is to monitor the web socket server and to make sure it runs smoothly and continuously.

    Try to test on as many browsers/devices as possible as this will decide on which websocket server implementation you choose. There are old and new protocols you have to watch out for.

    打赏 评论
  • dqwh26750 2012-07-05 15:22

    As @zaf states you are more likely to find a standalone PHP solution - not something that runs within Apache. That said there is a apache WebSocket module.

    However, the fundamental problem is that Apache wasn't built with maintaining many persistent connections in mind. It, along with PHP, is built on the idea that requests are made and responses are quickly sent back. This means that resources can very quickly be used up if you are holding requests open and you're going to need to look into horizontal scaling pretty quickly.

    Personally I think you have two options:

    1. Use an alternative realtime web technology solution and communicate between your web application and realtime web infrastructure using queues or short-lived requests (web services).
    2. Off load the handling of persistent connections and scaling of the realtime web infrastructure to a realtime web hosted service. I work for Pusher and we fall into this category.

    For both self-hosted and hosted options you can check out my realtime web tech guide.

    打赏 评论
  • dongpin4611 2013-07-11 12:59

    I introduced another websocket server: PHP Ratchet (Github).

    This is better and complete list of client & server side codes and browser support.

    Please check this link.

    打赏 评论
  • dongqiao1151 2013-09-24 20:42

    Another Path is to use a dedicated websocket server.

    Try Achex Websocket Server at www.achex.ca and checkout the tutorials.

    OR

    If you really want Apache, check out Apache Camel. (but you have to set it up and its a bit more complicated than achex server) http://camel.apache.org/websocket.html

    打赏 评论

相关推荐 更多相似问题