
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
protomux-rpc-client
Advanced tools
Connect to HyperDHT servers exposing protomux-rpc endpoints.
Manages connection state for you:
npm i protomux-rpc-client
For a quick-and-dirty client, simply initialise a ProtomuxRpcClient object, and call its makeRequest method (see API section for the contract).
For a cleaner approach, define a new class which exposes the available methods, abstracting away the encodings from the user. See the example.
const client = new ProtomuxRpcClient(dht, opts)Create a new Protomux RPC Client instance. dht is a hyperDHT instance.
opts include:
keyPair: use a specific keyPair to connect to the server, instead of the default one of the DHT instance.relayThrough: a function passed on to HyperDHT's connect method, to help relay when relevant. Default: null.backoffValues: an array of millisecond delays on reconnection attempts. The delay values are jittered. Default: [5000, 15000, 60000, 300000].suspended: a boolean for whether the client should be suspended on creation. Default: falserequestTimeout default time (in ms) before a request rejects with a timeout error. Default: 10000.msGcInterval: how often to run the garbage collection. Connections are kept open for at least msGcInterval ms of inactivity.maxConcurrentPerService: maximum number of concurrent request per service. Default: 16.client.openedWhether the client is opened as a boolean.
client.closedWhether the client is closed as a boolean.
client.suspendedWhether the client is currently suspended as a boolean.
client.dhtThe HyperDHT instance used to make connections.
client.nrConnectionsThe number of servers with which the client is currently attempting to keep connections open.
await client.makeRequest(key, methodName, args, opts)Creates a request to the server listening at the specified key (connecting if necessary) returning the response. methodName is a unique string that represents the method. args is the value(s) the method is called with.
Options:
{
requestEncoding, // Used to encode the `args`. Default: the protomux-rpc default.
responseEncoding, // Used to decode the response. Default: the protomux-rpc default.
id, // id of the protomux-rpc service
protocol, // protocol of the protomux-rpc service. Defaults to the server's public key.
timeout // time (in ms) before a request rejects with a timeout error. Defaults to the requestTimeout.
}
await client.suspend()Suspends all open RPC clients, destroying their RPC channel.
await client.resume()Resumes all suspended RPC clients by reconnecting.
await client.close()Closes all RPC clients and cleans up.
await client.gc()Forces a garbage collection. Normally never needed, since garbage collection runs at regular intervals.
client.on('gc', (nrRemoved) => {})The gc events are emitted whenever one or more clients are garbage colllected. nrRemoved indicates the amount of gc'd clients.
FAQs
Connect to protomux-rpc servers
The npm package protomux-rpc-client receives a total of 857 weekly downloads. As such, protomux-rpc-client popularity was classified as not popular.
We found that protomux-rpc-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.