So, over the years, I’ve released a few programs (all native C/C++) which have included automatic version checking, so they can let the user know when a new version is available. I’ve always done this by making a socket connection to my web server (previously Apache, now entirely Node.js) and asking for a file which just contains a version number. Pretty simple, right? Sure!
SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
char cmd = "GET http://www.bigscreensmallgames.com/BestBombermanEver/version.txt HTTP/1.0\r\n\r\n";
send(s, cmd, sizeof(cmd), 0);
And that’s about it. Note:
- This sends a single packet, and no router’s MTU is small enough that this packet would ever be fragmented, so it is, in theory, at least according to how TCP/IP is supposed to work, guaranteed to arrive as a single packet. Not that most web servers would care…
- I don’t bother sending any headers, specifically the Host header. Why would I if this works?
- There’s a bug in the code, it’s writing the NULL character into the packet after the final line feed.
Continue reading “The horrible things people’s routers do to my packets!”
Node.js can be pretty simple, but things get a bit more complicated when using Node.js to combine serving virtual hosts, some static sites, WebSockets (socket.io) used everywhere, some proxying to other apps, and some with request rewriting for hosting apps in a subdirectories.
I have a host running collection of websites and web apps, on various hostnames, running under various users, using various technologies. I often forget exactly how all of these things work, how they work together, and they have some subtle problems I don’t want to bother with having to resolve.
The proposed solution
It’s Node.js Apps all the way down!
Continue reading “It’s Node.js All the Way Down”
Original Post: 2013/09/30 on the (no longer running) Cloud Party Blog. Some notes added in-line while re-posting.
Goals, Background, and Requirements
At Cloud Party (repost note: no longer running after we were acquired by the Yahoo Games team), we have built a platform for users to create, discover, and share massive amounts of 3D content in a multi-user, social environment. When I was starting to configure our live servers, we needed a front-end load balancer (or “reverse proxy”) setup which met a lot of requirements:
Continue reading “Efficient Load Balancing and SSL Termination for WebSockets and Node.js”