[wp-hackers] WordPress and Websockets

Eric Mann eric at eam.me
Tue Sep 20 21:21:03 UTC 2011


I've bounced this idea on the WordPress StackExchange, in the support
forums, and informally to a few other developers via Twitter and in-person
at WordCamp Portland.  I have yet to hear a solid answer, though ... so I
wanted to bounce it by here, too.

I'm working on a plugin that, ideally, would make use of websockets to
communicate between the front-end and the WordPress backend.  Basically,
whenever a post is published on the backend, it should trigger an event on
the front-end for other users.  This can be done using old school AJAX and
long polling, but the point is more to make use of the cutting-edge
technology than to fall back on "what works."

Unfortunately, most users are running WordPress on an Apache server ... and
Apache doesn't natively support websockets.  There are some modules you can
add to make it work, but that's not an option for people running WP on a
shared host.

One option I have is to use Apache anyway.  It can be forced to work with
websockets using a few PHP scripts I found, but once the websocket is open
you essentially steal a persistent connection to Apache (which is itself a
blocking process).  So while this would work, and would probably work well
for low-traffic sites, it could easily lock up an ill-configured server or
crash someones system.

Another option is to host the websocket part of the system on my server
(where I can use Nginix, Node.js, or any other websocket-friendly server)
and have the plugin interface with my server.  The downside here is that my
system then becomes the bottleneck ...

My question to you: which option would you take?  Try to make due with
installed software, or move the mission-critical part of the application to
your own box?  Does anyone have experience implementing websockets in
WordPress already?  Is there something I'm missing?


More information about the wp-hackers mailing list