Hosting node.js applications in IIS on Windows

what is iisnode

iisnode is a native IIS module that allows hosting of node.js applications in IIS on Windows.

benefits

  • Process management. The iisnode module takes care of lifetime management of node.exe processes making it simple to improve overall reliability. You don’t have to implement infrastructure to start, stop, and monitor the processes.
  • Scalability on multi-core servers. Since node.exe is a single threaded process, it only scales to one CPU core. The iisnode module allows creation of multiple node.exe processes per application and load balances the HTTP traffic between them, therefore enabling full utilization of a server’s CPU capacity without requiring additional infrastructure code from an application developer.
  • Auto-update. The iisnode module ensures that whenever the node.js application is updated (i.e. the script file has changed), the node.exe processes are recycled. Ongoing requests are allowed to gracefully finish execution using the old version of the application, while all new requests are dispatched to the new version of the app.
  • Access to logs over HTTP. The iisnode module provides access the output of the node.exe process (e.g. generated by console.log calls) via HTTP. This facility is key in helping you debug node.js applications deployed to remote servers.
  • Side by side with other content types. The iisnode module integrates with IIS in a way that allows a single web site to contain a variety of content types. For example, a single site can contain a node.js application, static HTML and JavaScript files, PHP applications, and ASP.NET applications. This enables choosing the best tools for the job at hand as well progressive migration of existing applications.
  • Minimal changes to node.js application code. The iisnode module enables hosting of existing HTTP node.js applications with very minimal changes. Typically all that is required is to change the listed address of the HTTP server to one provided by the iisnode module via the process.env.PORT environment variable.
  • Integrated management experience. The issnode module is fully integrated with IIS configuration system and uses the same tools and mechanism as other IIS components for configuration and maintenance.
  • Other IIS benefits. Port sharing, security, URL rewriting, compression, caching, logging

prerequisities

building

For 32 bit Windows: msbuild /p:Platform=Win32 src\iisnode\iisnode.sln

For 64 bit Windows: msbuild /p:Platform=x64 src\iisnode\iisnode.sln

installing after build

build\debug\%PROCESSOR_ARCHITECTURE%\install.bat

installing from a download

samples

http://localhost/node (available after installation)

Which binary version do I need to download?

Please choose x86 flavors for installation on 32-bit Windows systems, and amd64 flavors for installation on 64-bit Windows systems.

Does iisnode block threads per request or connection

iisnode is completely async and does not block threads per request or connection. It does allocate small amounts of memory for active requests.

How do I report issues?

Please verify if your issue is already known by searching https://github.com/tjanczuk/iisnode/issues. If you don’t find it there, create a new issue report. Please include the following information with your bug report:

  • Windows OS version and bitness (32/64)
  • IIS version
  • which version of iisnode you are using (changelist number if compiled, binary package name if downloaded)
  • all interesting information from the IIS error page that displays (if any)
  • all interesting information IIS logs into the Event Viewer (http://msdn.microsoft.com/en-us/library/ms524984(v=vs.90).aspx)

I am getting a 503 response when running samples

If you run into a 503 status code with IIS reporting error code 0x5 (ERROR_ACCESS_DENIED), make sure the identity of the application pool running the site that hosts your node.js application has read & execute rights to node.exe on disk. If you are using the default IIS configuration (DefaultAppPool running under ApplicationPoolIdentity), you can set appropriate ACLs on the node.exe by running:

icacls %systemdrive%\node\node.exe /grant IIS_IUSRS:rx

resources & documentation

Advertisements

How a faster internet work?

DNS is like the phone book for the Internet. It converts human readable domains (www.opendns.com) to an IP address (208.69.38.160) that your computer can connect to. But what happens when you look up a business in the phone book and there are 50 locations? You probably want the location closest to you.

When trying to reach a website that exists in 50 locations around the world, you would want the same thing to happen. You want to be sent to the closest, fastest or least congested location automatically.  Until now, figuring out which location is closest to you was not possible with DNS alone.

Today, if you’re using OpenDNS or Google Public DNS and visiting a website or using a service provided by one of the participating networks or CDNs in the Global Internet Speedup then a truncated version of your IP address will be added into the DNS request. The Internet service or CDN will use this truncated IP address to make a more informed decision in how it responds so that you can be connected to the most optimal server. With this more intelligent routing, customers will have a better Internet experience with lower latency and faster speeds. Best of all, this integration is being done using an open standard that is available for any company to integrate into their own platform.

 

Continue reading

Installing CouchApp

Installing

The newest install instructions are always in the README

Requirements

  • Python 2.x >= 2.5 (Python 3.x will be supported soon)

Installing on all UNIXs

To install couchapp using easy_install you must make sure you have a recent version of distribute installed:

$ curl -O http://python-distribute.org/distribute_setup.py 
$ sudo python distribute_setup.py $ easy_install pip 

To install or upgrade to the latest released version of couchapp:

$ sudo pip install couchapp 

To install/upgrade development version :

$ sudo pip install git+http://github.com/couchapp/couchapp.git#egg=Couchapp 

Installing in a sandboxed environnement.

If you want to work in a sandboxed environnement which is recommended if you don’t want to not “pollute” your system, you can usevirtualenv :

$ curl -O http://python-distribute.org/distribute_setup.py 
$ sudo python distribute_setup.py 
$ easy_install pip $ pip install virtualenv 

Then to install couchapp :

$ pip -E couchapp_env install couchapp 

This command create a sandboxed environment in couchapp_env folder. To activate and work in this environment:

$ cd couchapp_env && . ./bin/activate 

Then you can work on your couchapps. I usually have a couchapps folder in couchapp_env where I put my couchapps.

Installing from source :

Follow instructions here

Installing on macosx

Using Couchapp Standalone executable :

Download Couchapp-0.8.1-macosx.zip on Github then double-click on the installer.

Using th python metapackage for macosx 10.5 or macosx 10.6

Using Homebrew

To install easily couchapp on MacOSX, it may be easier to use homebrew to install pip.

Once you installed homebrew, do :

$ brew install pip && pip install couchapp 

That’s it.

Installing on ubuntu

If you use [Ubuntu](http://www.ubuntu.com/-, you can update your system with packages from our PPA by addingppa:couchapp/couchapp to your system’s Software Sources.

Follow instructions here.

Installing on Windows

There are currently 3 methods to install on windows:

What is CouchApp?

What the HTTP is CouchApp?

This blog post is in response to a lot of well-deserved confusion in the community around CouchApps. We haven’t been clear enough in the past (either in technical description or in the notion of the project). I hope to change all that (with your help). This is just the beginning.

The Basics

A CouchApp is just a JavaScript and HTML5 app that can be served directly to the browser from CouchDB, without any other software in the stack. There are many benefits (and some constraints) to doing it this way. The first section of this article will address these tradeoffs.

In the bad old days (2008 and earlier), if you wanted to write a dynamic database-backed web application, you had to have an architecture that looked like a layer cake:

Browser (UI and links between pages)
-------------- HTTP ---------------
Application server (business logic, templates, etc)
--------- custom binary -----------
Persistence: MySQL, PostgreSQL, Oracle

 

Continue reading

Couchbase Mobile

Write mobile apps once, access anywhere.

Couchbase Mobile 

Couchbase Mobile allows developers to write web applications one time, synchronize multiple copies and share data and applications across any computing platform or mobile device. Easy to download and get started, Couchbase Mobile is fast, reliable and keeps the data on all your devices synchronized with the Couchbase database in the cloud.

We make sync easy.

Synchronization is a deeply hard problem. Couchbase was created from the ground up to solve this problem, so you don’t have to. Spend your time creating value for your users, and let us handle the hard part.

Ideal for user preferences, contacts, game scores, and enterprise data, Couchbase keeps all of your user’s mobile devices in sync with each other and backed up to the cloud.

Couchbase integrates with most popular mobile platforms. This includes Google’s Android, HP’s Palm WebOS, and Apple’s iOS, which includes the iPad and iPhone. Developers love it both for native development and HTML5 apps.

Anytime, anywhere access.

Mission critical applications don’t have the luxury to blame failures and slowness on spotty wireless access. The only true path to reliability is keeping your data on your device.

Couchbase Mobile works, online or off. It doesn’t depend on a constant Internet connection so it works all the time. Yes, offline happens.

Pure performance.

Users are turned off by slow applications, even when the slowness is due to network issues, not your code. With Couchbase Mobile, your application is always snappy, and never has to wait on wireless carriers or remote servers. Your users will thank you.

Couchbase is lightweight and saves battery life compared to traditional applications. By synchronizing data to the device, we optimize bandwidth usage and avoid expensive radio transmissions during everyday usage.

Reference : http://www.couchbase.com/products-and-services/mobile-couchbase

Check a valid URL of image

public static string CheckImageUrlExist(string ImageUrl)
{

  try
  {
    HttpWebRequest imageUrlRequest =
                   (HttpWebRequest)HttpWebRequest.Create(ImageUrl);

    if (imageUrlRequest == null) return NoImagePath;

    imageUrlRequest.Method = "HEAD";

    imageUrlRequest.GetResponse();
    return ImageUrl;
  }
  catch (UriFormatException)
  {
    return NoImagePath;
  }
  catch (WebException)
  {
    return NoImagePath;
  }
}

public static string NoImagePath{get{return "/Content/Images/noimage.png";}}

Setting up a Virtual Machine for Node.js development on Windows 7

If you run Windows 7 and you want to develop for the latest version of Node.js, you’re in for a bumpy ride. You can compile it under Cygwin, but the process is complex and doesn’t work for all versions. So what if:

  • You fear a later version of Node.js breaking on Windows again? (It was broken for two full minor versions, really quite a while.)
  • You don’t want to install Cygwin? (You madman, you really should.)
  • You are paranoid and want to be running your programs on the same environment you will be deploying them on?
  • You just can’t get the dang instructions to work?

Well, the solution isn’t to reformat and install Linux (though that could very easily help your productivity – fewer games being played, I’m sure). The solution is to install Node.js on a Virtual Machine with a shared drive. And honestly? It’s pretty easy. Three steps!

Step One: Install VirtualBox

Download VirtualBox here, then follow the instructions.

Step Two: Install Ubuntu Server

Download Ubuntu Server here, then create a new Virtual Machine. Name it what you will.

Under the “Network” tab in settings, change the adapter to a “Bridged Adapter”. This will force the machine to get a locally-addressable IP address.

Under the “Shared Folders” tab in settings, click the “Add” button, set the folder path to some new folder on your Windows 7 system. Set the folder name to something simple like “nodejs”.

Under the “Storage” tab, click on the “IDE Controller”, then click the little CD button. Navigate to where you downloaded the Ubuntu Server ISO and select it.

Now boot your new Virtual Machine and follow the Ubuntu Server setup options. Install whatever your little heart desires, but I recommend an SSH server so you don’t have to install it later.

Once it’s installed, run the following commands to install VirtualBox Guest Additions:

sudo apt-get update sudo apt-get install build-essential linux-headers-$(uname -r) 
sudo apt-get install virtualbox-ose-guest-x11 

Next, create a “nodejs” folder in your home directory, and add the following to your rc.local file (use the command “sudo nano /etc/init.d/rc.local”):

mount -t vboxsf nodejs /home/[YOUR_USER_NAME_GOES_HERE]/nodejs

Restart and your Windows folder should be hooked up to the nodejs folder on your Ubuntu VM.

Step Three: Install Node.js

This part’s super-simple. Run the following commands:

sudo apt-get update sudo apt-get install git-core curl build-essential openssl libssl-dev 
git clone https://github.com/joyent/node.git && cd node ./configure make sudo make 
install node -v cd curl http://npmjs.org/install.sh | sudo sh

That’s it! You’re set up with Node.js and Node’s package manager, NPM. If you want to test it, go to your nodejs folder (in either Windows or Ubuntu, both should be working now) and make a file called “hello.js”, and put the following in it:

var sys = require('sys'); sys.puts('Hello!');

Then go to your Ubuntu system and run:

node hello.js 

Reference : http://blog.danhulton.com/2011/03/18/setting-up-a-virtual-machine-for-node-js-development-on-windows-7/