Monday, 13 March 2017

Node.js socket.io and net socket conflict

I've been building a "hub" for my smart home. I'm running an express + socket.io server on port 3000 and using express to host my static content (the web client).

My server reaches out over HTTP using the request framework to fetch & update the state of my Philips Hue lights (port 80). It communicates these updates over socket.io to my web client. This works great.

Then I added support for my TP-Link HS100 switches. I'm using the net framework (built into Node), specifically the socket class. To fetch info & update a switch, I create a socket to a local IP on port 9999. This, by itself, works great.

However, once I enable both the Hue functionality and the TP-Link functionality, suddenly the socket.io events sent from my client aren't being received by the server, and my HTTP requests to Hue are taking much longer to resolve and sometimes timing out.

It seems like there is some kind of internal conflict between the net sockets and socket.io, even though they are operating on different ports. Any thoughts?



via TTillage

No comments:

Post a Comment