Noobhub Multiplayer Server for Corona SDK in 5 Minutes

NoobHub is a free multi-user node.js based server and a Corona SDK client that works for Corona based projects, most importantly, games.  Setting up NoobHub is extremely simple, and I’ll show you how to do it in about five minutes of your time.

These set-up instructions are well enough for development purposes, giving you a chance to test game ideas, but in production you will need to apply additional steps to secure your server.

If you need more help in setting up a production server, be sure to ask your local server administration guru.

NoobHub in 5 Minutes

Preparation

We will need to get a couple of things in order before we start the installation.  So make sure you have the following steps taken care of before we proceed.

DigitalOcean

For the example I am going to be using DigitalOcean as the cloud provider.  They offer an extremely simple control panel, and can wind up a server instance in a little under a minute in most cases.  So set up an account, if you don’t already have one.  We will be using a $5 plan in our example.  If you only turn the instance on when your testing, then it will cost much less.  You are only charged for what you use, up to $5 month.

Click here to use our referral link and get 2 months FREE!

 NoobHub

Download the latest NoobHub files here at this link.  Extract the files.  We will be using the Corona SDK project in the lua-corona client in the client folder.

Setting up the Server

Creating the Droplet

Log into your DigitalOcean control panel and click the large Create Droplet button in the upper right corner.

noob-step1

Enter a hostname, you can use something like “noobhub.yourname” — this is  not a domain name, just an internal reference.

noob-step2

Select a plan from the presented choices.  A 512MB droplet will be fine for our testing server.

noob-step3

Choose a region.  It makes sense to choose a location nearest to your users.  You can also deploy droplets in different regions, and connect to them appropriately.

noob-step4

Under Linux Distributions click on the CentOS icon, and then select the x64 version from the choices presented.

noobstepnew

After double checking your selections, scroll to the bottom and click the green Create Droplet button.

noob-step6

Your droplet will start initializing.  Very shortly you should receive an email with your log-in information.

Install Server Applications

Open up a terminal client, Terminal (/Applications/Utilities) on the Mac, or PuTTy is fine for Windows.

When entering commands in the terminal, be sure to press the Return key after each entry.

With the IP address of your new Droplet handy, SSH into the server.

ssh root@your.droplet.ip

Confirm the RSA fingerprint key by entering “yes” and pressing enter.

When prompted, enter the password you received in the email.  You can copy and paste the value in.

Once you are successfully logged in, the first thing you should do is change the password, on the command line, type:

passwd

You’ll be asked to enter, and confirm your new password. The next time you log into the server, you will need to use this new password.

Now we need to update the application sources in CentOS.  Enter the following on the command line and press enter:

yum -y update

Let it do its thing.  You should see some output in the terminal window.

Next we need to add an extra repository for CentOS with the two following commands:

curl -O http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -Uvh epel-release-6*.rpm

Now we install node.js, npm, and git onto the server by using the following command:

yum -y install nodejs npm git

After the installation is complete we need to change the directory we are currently in.  Enter the following:

cd /home

Press enter and you will be taken to the home directory on the server.  Which will be a good place to put our files.

Download the latest version of the NoobHub server using git.  This allows us to keep the server up-to-date easily.

git clone https://github.com/Overtorment/NoobHub.git

Once that is done, we can start the server up.  But before we do that, we should make sure that the NoobHub server will always stay running, even after we close the terminal connection.  To do that, we need to install a tool called forever, like so:

npm install forever -g

Now, when we want to start up the NoobHub server we first need to make sure we are in the home directory (see previous steps), and enter the following on the command line:

forever start --spinSleepTime 10000 NoobHub/server/node.js

Now the NoobHub app is running, and if anything goes wrong, after 10 seconds it will restart the NoobHub instance.

Connecting the Client

Open the main.lua file that was included in the NoobHub client folder that you downloaded earlier.  It’s located in the lua-corona folder.  Change the following line:

hub = noobhub.new({ server = "your.droplet.ip"; port = 1337; });

noob-step23

Open up the main.lua in your Corona Simulator, and you should see some output in the Corona Terminal as the app sends a ping and receives a pong.

noob-step24

 Controlling the Server

You may need to start / stop NoobHub, as well as, view the log file for debugging purposes.  To do that we need to look at using the forever program a bit more.

Listing Running Processes

To control your NoobHub process, we first need to see what reference number it has been assigned by forever.  Unless you are using forever to run multiple node.js applications, the internal reference number is most likely 0 (zero).  To list the processes enter the following in the command line:

forever list

Stopping NoobHub

When you want to stop NoobHub, you can issue a command to forever, using the internal reference number.  In the case that the number is 0 (zero) type the following in the command line:

forever stop 0

This will stop the NoobHub instance, if you need to restart the instance, enter the following as shown previously:

forever start --spinSleepTime 10000 NoobHub/server/node.js

Viewing the NoobHub Log file

Using the forever list command as shown above, you can find the path to the NoobHub log file for that particular instance.

noob-step28

With that information enter the following on the command line, as an example:

tail -f /root/.forever/T2hd.log

The case does matter, so make sure to enter it exactly as shown on your forever process list.  When clients are connected, you will see the running output in the terminal window.

noob-step30

To stop the output and return to the command line, use Control-C on your keyboard.

Start Making Games

Now that your NoobHub instance is up and running you can start developing your next multiplayer masterpiece.  Learn more about using NoobHub by checking out the following links:

http://forums.coronalabs.com/topic/32775-noobhub-free-opensource-multiplayer-and-network-messaging-for-coronasdk

https://github.com/Overtorment/NoobHub

 I hope that this tutorial has been helpful in getting NoobHub running.  Please share this information to those who can benefit.

Advertisements

6 thoughts on “Noobhub Multiplayer Server for Corona SDK in 5 Minutes

  1. Thanks a lot for this guide.

    I am able to communicate with the server using the simulator, but unfortunately cannot connect when I build and put my application on my Android mobile phone.

    I am getting the following error :

    I/Corona ( 3295): Noobhub connection error: permission denied
    I/Corona ( 3295): Problems with server..?
    I/System.out( 3295): WARNING: Could not load font Helvetica-Bold. Using default.

    Is this to do with the port number on device or is the error related to something else?

    Thanks a lot.

    Like

  2. Great tutorial, how can one determine the plan/pricing for the cloud service? Have you been able to do a stress-test to handle simultaneous connections (how many can the $5 plan handle) Is it fast real time for arcade game use?

    Like

    1. Hi Raphael,

      I have not run any tests yet, just got to installing it. Supposedly node.js can handle a lot of connections on even smaller sized hardware, what that means I’m not sure, but will update when I have a better idea.

      You can also visit the forum thread listed above, someone may be able to provide better insight.

      Cheers.

      Like

Comments are closed.