Socket.IO integration with Apache2 for live update calendar

Go To StackoverFlow.com

0

I'm trying to build a calendar with live update using Socket.IO Websocket. I managed to get the Socket.IO server running on port 8181 but my calendar.php is managed via apache on port 80.

What I'm looking to do is to use my calendar.php with apache and at the same time connect to my Socket.IO server on port 8181 (or bind it to port 80 with apache but that seem to be pretty complicated, I tried back proxy but didn't work) to receive updates when someone edited a event in the calendar. My events are stored in a SQL database.

So is there a way to use Socket.IO on port 8181 in a php page served by apache on port 80?

Thanks!

2012-04-04 23:14
by exomic


1

I'm not sure I understand your issue. Once the page is served by PHP on port 80, you would connect to your socket.io server on 8181 in the simplest set up.

And from then on you wouldn't need to interact with php again since you'd probably be sending messages to your socket.io server to process.

For load balancing socket.io, I think you can use HAProxy and I think LearnBoost has an alternative on Github also. I actually haven't gotten to this step with my app yet, so I can't give too much info here.

But yeah, your socket.io server should receive, process and send messages. You can also use redis for Pub/Sub if you have multiple instances of socket.io running.

There is a node module for an asynchronous MySQL driver that will allow you to interact with your Database directly. I'm using MongoDb in my app, so I've never used the MySQL modules.

I guess alternatively, you could use your PHP server as a web service and your socket.io server could interact with it, but I imagine it would be slow to do it like that.

Hopefully that clears things up. Seems like your set up will already work in a dev environment.

2012-04-05 00:22
by Gohn67
Ads