i want to retrive data from this websocket api, where is my code

    import { WebSocketServer } from 'ws'
let socket = new WebSocketServer('wss://ws.blockchain.info/inv');
 socket.on('error', console.error);

when i run , i get this error :

/home/bp/node_modules/ws/lib/websocket-server.js:81 throw new TypeError( ^

TypeError: One and only one of the "port", "server", or "noServer" options must be specified at new WebSocketServer (/home/bp/node_modules/ws/lib/websocket-server.js:81:13) at file:///home/bp/bp.js:201:16 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:533:24) at async loadESM (node:internal/process/esm_loader:91:5) at async handleMainPromise (node:internal/modules/run_main:65:12)

ws version ^8.13.0

Node.js Version v16.17.0

System OS: Linux 4.4 Ubuntu 16.04.7 LTS (Xenial Xerus) CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz Memory: 1.00 GB / 2.00 GB Container: Yes Shell: 4.3.48 - /bin/bash

How can i fix this error ?


1 Answer 1


if you have a same issues, where is the solution https://github.com/websockets/ws/issues/2131#issuecomment-1475364391

import { WebSocket } from 'ws'
const socket = new WebSocket('wss://ws.blockchain.info/inv');
socket.on('error', console.error);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.