{"id":48788,"library":"non-native-websocket","title":"WebSocket-Node","description":"A pure JavaScript implementation of the WebSocket protocol (RFC 6455) for Node.js, supporting protocol versions 8 and 13. Current stable version is 1.0.8, released in 2012. The library includes both client and server implementations. Key differentiators: native modules are optional (fallback to JS), supports Autobahn test suite, and is one of the fastest WebSocket libraries for Node.js. Note: This package was originally published as non-native-websocket but is the precursor to the widely-used 'websocket' npm package by the same author.","status":"deprecated","version":"0.0.1","language":"javascript","source_language":"en","source_url":"http://github.com/gaye/WebSocket-Node","tags":["javascript","websocket","websockets","socket","networking","comet","push"],"install":[{"cmd":"npm install non-native-websocket","lang":"bash","label":"npm"},{"cmd":"yarn add non-native-websocket","lang":"bash","label":"yarn"},{"cmd":"pnpm add non-native-websocket","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional native addon for UTF-8 validation and efficient XOR masking; if compilation fails, pure JS fallback is used","package":"nan","optional":true}],"imports":[{"note":"CommonJS require is also acceptable. The package does not ship TypeScript definitions.","wrong":"var WebSocketClient = require('non-native-websocket').WebSocketClient","symbol":"WebSocketClient","correct":"import { WebSocketClient } from 'non-native-websocket'"},{"note":"Both default and named exports are available. For ESM, named import is preferred.","wrong":"const WebSocketServer = require('non-native-websocket').WebSocketServer","symbol":"WebSocketServer","correct":"import { WebSocketServer } from 'non-native-websocket'"},{"note":"This provides a W3C-compliant WebSocket client API for browsers.","wrong":"const w3c = require('non-native-websocket').w3cwebsocket","symbol":"w3cwebsocket","correct":"import { w3cwebsocket } from 'non-native-websocket'"}],"quickstart":{"code":"import { WebSocketClient, WebSocketServer } from 'non-native-websocket';\n\n// Server\nconst serverConfig = {\n  httpServer: require('http').createServer().listen(8080),\n  autoAcceptConnections: false\n};\nconst wsServer = new WebSocketServer(serverConfig);\nwsServer.on('request', (request) => {\n  const connection = request.accept(null, request.origin);\n  connection.on('message', (message) => {\n    if (message.type === 'utf8') {\n      connection.sendUTF(message.utf8Data);\n    }\n  });\n  connection.on('close', (reasonCode, description) => {\n    console.log('Peer disconnected');\n  });\n});\n\n// Client\nconst client = new WebSocketClient();\nclient.on('connectFailed', (error) => console.log('Connect Error: ' + error.toString()));\nclient.on('connect', (connection) => {\n  connection.on('error', (error) => console.log(\"Connection Error: \" + error.toString()));\n  connection.on('close', () => console.log('Connection closed'));\n  connection.on('message', (message) => {\n    console.log(\"Received: \" + message.utf8Data);\n  });\n  connection.sendUTF('Hello');\n});\nclient.connect('ws://localhost:8080/', null);","lang":"javascript","description":"Shows how to create a WebSocket server and client using the library, handling connection requests, messages, and errors."},"warnings":[{"fix":"No action required unless you need strict UTF-8 validation; then ensure native build tools (node-gyp) are installed or use a newer version of the library (e.g., 'websocket' package).","message":"Native modules are optional since version 1.0.7; if compilation fails, UTF-8 validation is skipped and XOR masking is slower.","severity":"breaking","affected_versions":">=1.0.7"},{"fix":"Upgrade to Node v0.8+ or use a newer library version that does not have this restriction.","message":"Unicode characters outside the Basic Multilingual Plane (BMP) are truncated under Node v0.6.x due to lack of surrogate pair support.","severity":"gotcha","affected_versions":">=1.0.0 <1.0.7"},{"fix":"Migrate to the 'websocket' package for continued support and updates.","message":"This package is deprecated in favor of the 'websocket' npm package, which is the successor with the same API and active maintenance.","severity":"deprecated","affected_versions":"*"},{"fix":"For legacy browser support, see https://gist.github.com/1428579 or use a polyfill.","message":"The library does not support draft-75/draft-76/draft-00 legacy browser versions; use a different library for old browser compatibility.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.0.8':26 '13':21 '2012':29 '6455':13 '8':19 'author':87 'autobahn':48 'client':34 'comet':93 'current':22 'differenti':39 'fallback':44 'fastest':56 'implement':7,37 'includ':32 'javascript':6,88 'js':46 'key':38 'librari':31,58 'modul':41 'nativ':40,70 'network':92 'node':3 'node.js':15,60 'non':69 'non-native-websocket':68 'note':61 'npm':82 'one':53 'option':43 'origin':65 'packag':63,83 'precursor':75 'protocol':11,17 'publish':66 'pure':5 'push':94 'releas':27 'rfc':12 'server':36 'socket':91 'stabl':23 'suit':50 'support':16,47 'test':49 'use':80 'version':18,24 'websocket':2,10,57,71,81,89,90 'websocket-nod':1 'wide':79 'widely-us':78","created_at":"2026-06-07T16:58:28.168144+00:00","updated_at":"2026-06-07T16:58:28.168144+00:00","problems":[{"fix":"Use the 'websocket' package instead: npm install websocket","cause":"The package is deprecated and may have been removed from npm or not installed correctly.","error":"Error: Cannot find module 'non-native-websocket'"},{"fix":"Install native build dependencies or use version >=1.0.7 where native modules are optional.","cause":"Missing build tools (node-gyp, python, etc.) or incompatible Node version.","error":"Error: native module compilation failed"},{"fix":"Ensure you call sendUTF on the connection object received in the 'connect' event.","cause":"Incorrect usage: sendUTF is a method of the connection object, not the client.","error":"TypeError: Object #<Object> has no method 'sendUTF'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/gaye/WebSocket-Node","github":"http://github.com/gaye/WebSocket-Node","docs":null,"changelog":null,"pypi":null,"npm":"non-native-websocket","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}