NodeJS + Socket.io Random Freezing

Mar 30

So I recently found this out the hard way… if you are running a socket.io service on a non-standard port and have a firewall (which you most likely do lol) then you may be experiencing random freezing. TO MY KNOWLEDGE, this is caused by the UDP port being blocked by the firewall.

I was experiencing this issue and I unblocked that port in the firewall yesterday and I have not seen my app freeze yet! 😀

YAY!

Points for super short blog entry lol but just in case anyone can benefit from this 😛

Filed Under: Dev

NodeJS + Socket.io + PHP

Mar 9

Over the past few days, I’ve been writing a custom Chat in an attempt to optimize resource consumption and make use of AWESOME web sockets. I stumbled across the idea of being able to “push” events that happen on the site such as receiving new messages, or new posts on topics you follow to the shoutbox. As a result I went out looking for a way of PHP connecting to a nodeJS server and being able to broadcast to the socket from there.

The result is a sort of hack which involves creating a secondary HTTP server and listening for connections. When a connection is received, the URL is parsed with the parameters and action can be taken accordingly 🙂

Here’s the code:

To push to it from PHP just fire a file_get_contents() or curl request to it. For example the one I use is as follows:

Hopefully this can help someone else with the same issue I had 😀

Filed Under: Dev