Skip to content
Demo of WebSocket app for OpenShift using node.js, Bootstrap and jQuery
JavaScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

WebSocket example

How to use WebSockets, Bootstrap, jQuery and node.js in RedHat's OpenShift Cloud.

Live Example is available on:

Setup for Ubuntu 14.04.4 LTS

  • On your ubuntu invoke:
sudo apt-get install ruby-full build-essential git npm nodejs
# install rhc only if you plan to use OpenShift containers
sudo gem install rhc

NOTE: On same versions of Ubuntu there is missing link /usr/bin/node -> nodejs. You may try:

which node ||
   sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

Setup for OpenShift (optional)

This application can be run both standalone (on your local computer) or in OpenShift container. Follow these instructions bellow to deploy this app on OpenShift:

rhc setup
# confirm hostname <ENTER>
# enter your OpenShift Login and password
# confirm token creation
# confirm upload of ssh key
  • Create directory for openshift projects:
mkdir -p ~/projects/openshift
  • Change working directory there
cd ~/projects/openshift
  • Create OpenShift NodeJs application from my GitHub repo using this command:
rhc app-create ws2 nodejs-0.10  --from-code

NOTE: If you exceeded OpenShift's limit for free apps (max 3 apps) you can use this command to delete extra app:

rhc apps # show apps
rhc app delete APP_NAME

Your application should be successfully deployed on url like

Setup for standalone mode only

If you plan use this application without OpenShift then just issue these commands:

cd ~/my_projects_dirs
git clone ws2

Follow next section:

Development and Redeployment

  • Just enter ws2 subdirectory and edit what needed
  • for the 1st time or after packages.json change issue
npm install
  • issue this command to run application locally
npm start
  • open url [http://localhost:5000] in your browser
  • to redeploy modified app to OpenShift use:
git commit -am "My modification"
git push origin master

Creating empty node.js application on OpenShift

Skip this step (it is here for documentary purpose only)

# do not do this - 
rhc app-create ws2 nodejs-0.10
cd ws2
npm install
npm install swig --save
npm install ws --save


This sample is based on lot of code snippets including:

You can’t perform that action at this time.