rsp/node-websocket-vs-socket.io


Comparing WebSocket and Socket.IO on Node.js with Express.js

Host: GitHub

License: MIT

Language: JavaScript


Node WebSocket vs. Socket.IO

npm install -g websocket-vs-socket.io
Code Climate Known Vulnerabilities Downloads

Comparing WebSocket and Socket.IO on Node.js with Express.js - example server-side and client-side code to see the basic usage of both WebSocket and Socket.IO in an Express.js app, with info on how to compare the actual network traffic (which is commonly misunderstood by many online sources).

See those Stack Overflow answers where this code was used:

Quick start

Install:

npm i -g websocket-vs-socket.io

Run the server:

websocket-vs-socket.io

Open http://localhost:3001/ in your browser, open developer tools with Shift+Ctrl+I, open the Network tab and reload the page with Ctrl+R to see the network traffic for the WebSocket version.

Open http://localhost:3002/ in your browser, open developer tools with Shift+Ctrl+I, open the Network tab and reload the page with Ctrl+R to see the network traffic for the Socket.IO version.

Uninstall the server:

npm rm -g websocket-vs-socket.io

For more options, see Installation below.

Installation

More options to install the server.

Installing from npm

Installing globally with npm:

# install globally with npm:
npm i -g websocket-vs-socket.io
# run the server:
websocket-vs-socket.io
# uninstall:
npm rm -g websocket-vs-socket.io

Installing locally with npm:

# create a directory:
mkdir ~/websocket-vs-socket.io
cd ~/websocket-vs-socket.io
# install the module:
npm i websocket-vs-socket.io
# run the server:
./node_modules/.bin/websocket-vs-socket.io
# uninstall the module:
npm rm websocket-vs-socket.io
# or remove the entire directory:
rm -rvf ~/websocket-vs-socket.io

Installing from GitHub

You can clone the git repo and install npm dependencies:

# clone the git repo:
git clone git@github.com:rsp/node-websocket-vs-socket.io.git
cd node-websocket-vs-socket.io
# install dependencies:
npm i
# run the server:
./ws-vs-si.js

Alternatively, instead of cloning the repo you can download a ZIP file:

# download and unzip the zip file:
wget https://github.com/rsp/node-websocket-vs-socket.io/archive/master.zip
unzip master.zip
cd node-websocket-vs-socket.io-master
# install dependencies:
npm i
# run the server:
./ws-vs-si.js

Running

You start the server with either websocket-vs-socket.io (if you installed from npm) or ./ws-vs-si.js (if you installed from the GitHub repo). See Installation above for details.

When the server is running, you can open in your browser:

In Firefox or Chrome, you can open developer tools with Shift+Ctrl+I, open the Network tab and reload the page with Ctrl+R to see the network traffic for both versions.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski - https://github.com/rsp

License

MIT License (Expat). See LICENSE.md for details.

Project Statistics

Sourcerank 5
Repository Size 31.3 KB
Stars 19
Forks 2
Watchers 1
Open issues 2
Dependencies 3
Contributors 1
Tags 13
Created
Last updated
Last pushed

Top Contributors See all

Rafał Pocztarski

Packages Referencing this Repo

websocket-vs-socket.io
Comparing WebSocket and Socket.IO on Node.js with Express.js
Latest release 0.0.13 - Updated - 19 stars

Recent Tags See all

v0.0.13 October 04, 2016
v0.0.12 October 03, 2016
v0.0.11 September 30, 2016
v0.0.10 July 25, 2016
v0.0.9 July 25, 2016
v0.0.8 July 25, 2016
v0.0.7 July 25, 2016
v0.0.6 July 25, 2016
v0.0.5 July 20, 2016
v0.0.4 July 20, 2016
v0.0.3 July 20, 2016
v0.0.2 July 20, 2016
v0.0.1 July 20, 2016

Something wrong with this page? Make a suggestion

Last synced: 2016-10-04 09:54:06 UTC

Login to resync this repository