All Projects → feross → Simple Websocket

feross / Simple Websocket

Licence: mit
Simple, EventEmitter API for WebSockets

Programming Languages

184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Simple Websocket

Render Media
Intelligently render media files in the browser
Stars: ✭ 181 (+13.84%)
Mutual labels:  stream, streaming, browser
JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
Stars: ✭ 1,202 (+655.97%)
Mutual labels:  websocket, browser
String To Stream
Convert a string into a stream (streams2)
Stars: ✭ 75 (-52.83%)
Mutual labels:  stream, browser
brain.js is a GPU accelerated library for Neural Networks written in JavaScript.
Stars: ✭ 12,358 (+7672.33%)
Mutual labels:  stream, browser
Akka Http
The Streaming-first HTTP server/module of Akka
Stars: ✭ 1,163 (+631.45%)
Mutual labels:  websocket, streaming
Sec Api EDGAR API | search & filter SEC filings | over 150 form types supported | 10-Q, 10-K, 8, 4, 13, S-11, ... | insider trading
Stars: ✭ 71 (-55.35%)
Mutual labels:  stream, websocket
HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
Stars: ✭ 10,791 (+6686.79%)
Mutual labels:  stream, streaming
Window-Based Hybrid CPU/GPU Stream Processing Engine
Stars: ✭ 35 (-77.99%)
Mutual labels:  stream, streaming
Nginx Vod Module
NGINX-based MP4 Repackager
Stars: ✭ 1,378 (+766.67%)
Mutual labels:  stream, streaming
Twitch VOD tool which recovers all VODs including those that are sub only or deleted.
Stars: ✭ 123 (-22.64%)
Mutual labels:  stream, streaming
Webcam, PiCamera streaming over the network with Python made easy.
Stars: ✭ 133 (-16.35%)
Mutual labels:  stream, streaming
Cypher Stream
Neo4j Cypher queries as Node.js object streams
Stars: ✭ 58 (-63.52%)
Mutual labels:  stream, streaming
Ws Wrapper
Lightweight WebSocket lib with event handling, requests, and channels
Stars: ✭ 58 (-63.52%)
Mutual labels:  websocket, browser
SQL-based streaming analytics platform at scale
Stars: ✭ 1,178 (+640.88%)
Mutual labels:  stream, streaming
Async peer communication protocol & library
Stars: ✭ 1,036 (+551.57%)
Mutual labels:  websocket, streaming
Rtmp Rtsp Stream Client Java
Library to stream in rtmp and rtsp for Android. All code in Java
Stars: ✭ 1,338 (+741.51%)
Mutual labels:  stream, streaming
Azure Event Hubs Spark
Enabling Continuous Data Processing with Apache Spark and Azure Event Hubs
Stars: ✭ 140 (-11.95%)
Mutual labels:  stream, streaming
Streaming music player that finds free music for you
Stars: ✭ 7,133 (+4386.16%)
Mutual labels:  stream, streaming
Interactive Sound Board for Mixer. Microsoft shut Mixer down, so this application no longer works. RIP Mixer.
Stars: ✭ 27 (-83.02%)
Mutual labels:  stream, streaming
Node Tcp Streaming Server
Experimental TCP video streaming server written in node.js. Streaming over TCP and redistributing using WebSockets.
Stars: ✭ 100 (-37.11%)
Mutual labels:  websocket, streaming

simple-websocket travis npm downloads javascript style guide

Simple, EventEmitter API for WebSockets

Sauce Test Status


  • super simple API for working with WebSockets in the browser
  • supports text and binary data
  • node.js duplex stream interface
  • client & server implementations

This package is used by WebTorrent.


npm install simple-websocket

This package works in the browser with browserify. If you do not use a bundler, you can use the simplewebsocket.min.js standalone script directly in a <script> tag. This exports a SimpleWebsocket constructor on window. Wherever you see Socket in the examples below, substitute that with SimpleWebsocket.

real-world applications that use simple-websocket

  • Virus Cafe - Make a friend in 2 minutes
  • WebTorrent - The streaming torrent app
  • StudyNotes - Helping students learn faster and better
  • bittorrent-tracker - Simple, robust, BitTorrent tracker (client & server) implementation
  • - Secure, anonymous, streaming file transfer
  • lxjs-chat - Omegle chat clone
  • Metastream - Watch streaming media with friends.
  • [ your application here - send a PR ]


var Socket = require('simple-websocket')

var socket = new Socket('wss://')
socket.on('connect', function () {
  // socket is connected!

socket.on('data', function (data) {
  console.log('got message: ' + data)


socket = new Socket(url)

Create a new WebSocket connection to the server at url. This usage is a shorthand for socket = new Socket({ url: url })

socket = new Socket(opts)

If opts.url is specified as a string, then a WebSocket connection will be created to the server at opts.url.

If opts.socket is specified as an instance of a raw WebSocket object, then the given WebSocket object will be used and one will not be automatically be created internally. (This is for advanced users.)

Other properties on opts will be passed through to the underlying superclass, stream.Duplex.


Send text/binary data to the WebSocket server. data can be any of several types: String, Buffer (see buffer), TypedArrayView (Uint8Array, etc.), ArrayBuffer, or Blob (in browsers that support it).

Note: If this method is called before the socket.on('connect') event has fired, then data will be buffered.


Destroy and cleanup this websocket connection.

If the optional err parameter is passed, then it will be emitted as an 'error' event on the stream.


Detect WebSocket support in the javascript environment.

var Socket = require('simple-websocket')

  // websocket support!
} else {
  // fallback


socket.on('connect', function () {})

Fired when the websocket connection is ready to use.

socket.on('data', function (data) {})

Received a message from the websocket server.

data will be either a String or a Buffer/Uint8Array (see buffer). JSON strings will be parsed and the resulting Object emitted.

socket.on('close', function () {})

Called when the websocket connection has closed.

socket.on('error', function (err) {})

err is an Error object.

Fired when a fatal error occurs.


The server implementation is basically ws but the 'connection' event provides sockets that are instances of simple-websocket, i.e. they are duplex streams.

var Server = require('simple-websocket/server')

var server = new Server({ port: port }) // see `ws` docs for other options

server.on('connection', function (socket) {
  socket.on('data', function (data) {})
  socket.on('close', function () {})
  socket.on('error', function (err) {})



MIT. Copyright (c) Feross Aboukhadijeh.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].