{"id":49734,"library":"websocket-rpc-client","title":"websocket-rpc-client","description":"A lightweight JavaScript library implementing JSON-RPC 2.0 over WebSockets, providing promise-based request/response handling and event subscription. Version 0.2.0 is the latest, with no clear release cadence. Designed for browser environments, it offers automatic reconnection with configurable timeout and retry count. Compared to alternatives like json-rpc-ws or isomorphic-wsrpc, this library provides a simple static API and built-in reconnect logic, but lacks TypeScript types and has no recent updates.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/draedful/websocket-rpc-client","tags":["javascript","websocket","browser","websocket-client","json-rpc","promise"],"install":[{"cmd":"npm install websocket-rpc-client","lang":"bash","label":"npm"},{"cmd":"yarn add websocket-rpc-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add websocket-rpc-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS require() works in Node but the library targets browsers; ESM import is recommended.","wrong":"const WS = require('websocket-rpc-client')","symbol":"default","correct":"import WS from 'websocket-rpc-client'"},{"note":"Also valid for all symbols as namespace import.","symbol":"default (named alternative)","correct":"import * as WS from 'websocket-rpc-client'"},{"note":"start is not a named export; it's a method on the default export.","wrong":"import { start } from 'websocket-rpc-client'","symbol":"start","correct":"import WS from 'websocket-rpc-client'; WS.start(params)"}],"quickstart":{"code":"import WS from 'websocket-rpc-client';\n\nWS.start({\n  url: 'ws://localhost:8080/ws',\n  reconnectTimeout: 3000,\n  reconnectCount: 5\n}).then(() => {\n  console.log('Connected');\n  WS.send('echo', { message: 'Hello' }).then(resp => {\n    console.log('Response:', resp);\n  }).catch(err => console.error('Send error:', err));\n}).catch(err => console.error('Connection failed:', err));\n\nWS.subscribe('onMessage', params => {\n  console.log('Received:', params);\n});","lang":"javascript","description":"Shows how to establish a WebSocket JSON-RPC connection, send a request, handle the response, and subscribe to events."},"warnings":[{"fix":"Install 'ws' and assign it to global.WebSocket before importing the library.","message":"The library expects to run in a browser environment; using it in Node.js requires a WebSocket polyfill (e.g., 'ws' package).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always ensure 'start' promise resolves before using other methods.","message":"The 'start' method must be called before any 'send' or 'subscribe' calls, or they may fail silently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Only one WebSocket connection can be managed at a time; disconnect and reconnect as needed.","message":"The library uses a static singleton connection; creating multiple instances is not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider evaluating alternatives for active maintenance.","message":"No known deprecated APIs, but the library has not been updated since initial release.","severity":"deprecated","affected_versions":"0.2.0"}],"env_vars":null,"search_vec":"'0.2.0':26 '2.0':13 'altern':51 'api':67 'automat':41 'base':19 'browser':37,85 'built':70 'built-in':69 'cadenc':34 'clear':32 'client':4,88 'compar':49 'configur':44 'count':48 'design':35 'environ':38 'event':23 'handl':21 'implement':9 'isomorph':59 'isomorphic-wsrpc':58 'javascript':7,83 'json':11,54,90 'json-rpc':10,89 'json-rpc-w':53 'lack':75 'latest':29 'librari':8,62 'lightweight':6 'like':52 'logic':73 'offer':40 'promis':18,92 'promise-bas':17 'provid':16,63 'recent':81 'reconnect':42,72 'releas':33 'request/response':20 'retri':47 'rpc':3,12,55,91 'simpl':65 'static':66 'subscript':24 'timeout':45 'type':77 'typescript':76 'updat':82 'version':25 'websocket':2,15,84,87 'websocket-cli':86 'websocket-rpc-cli':1 'ws':56 'wsrpc':60","created_at":"2026-06-07T17:03:19.974538+00:00","updated_at":"2026-06-07T17:03:19.974538+00:00","problems":[{"fix":"Use import WS from 'websocket-rpc-client' (default import).","cause":"Imported named export instead of default export.","error":"TypeError: WS.start is not a function"},{"fix":"Install 'ws' package and set global.WebSocket = require('ws'); before importing the library.","cause":"Running in Node.js environment without global WebSocket.","error":"ReferenceError: WebSocket is not defined"},{"fix":"Call send or subscribe only after the promise from WS.start() resolves.","cause":"Attempted to send or subscribe before the connection was established.","error":"Error: Not connected"}],"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/draedful/websocket-rpc-client","github":"https://github.com/draedful/websocket-rpc-client","docs":null,"changelog":null,"pypi":null,"npm":"websocket-rpc-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging","communication"],"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}}