Jayson is a comprehensive JavaScript library providing both server and client implementations for the JSON-RPC 2.0 and 1.0 specifications. It enables developers to build robust remote procedure call systems over HTTP, HTTPS, TCP, TLS, and WebSockets connections, primarily targeting Node.js environments. The current stable version is 4.3.0. The project maintains an active development pace with ongoing bug fixes and feature enhancements, though major version releases are not on a fixed cadence. Key differentiators include its support for simultaneous server interfaces, relaying requests, flexible method routing, transparent serialization using revivers/replacers, and first-class Promises support, making it suitable for complex distributed systems and microservices architectures. It also ships with full TypeScript type definitions since v2.1.0.
npm install jaysonVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up a basic Jayson HTTP JSON-RPC server with both callback-based and promise-based methods, and then invoking these methods from a Jayson HTTP client.
Review your application for direct or indirect dependencies on `lodash` when interacting with Jayson methods and adjust data structures or serialization logic as needed. Ensure objects and arrays passed to Jayson conform to standard JavaScript types.
Update server method signatures to ensure all JSON-RPC parameters are accessed from the first argument. If you previously used `collect` functionality, you may need to implement custom parameter collection logic.
Always construct JSON-RPC compliant error objects in your server methods. When using the callback signature `callback(error, result)`, ensure `error` is a structured object, not just an `Error` instance. For promise-based methods, throw an object matching the JSON-RPC error structure.
Configure CORS headers on your Jayson HTTP server (e.g., `server.http({ cors: true, headers: { /* ... */ } })`) or ensure client and server are on the same origin. For browser clients, you might need to use `require('jayson/lib/client/browser')` with a custom transport.Migrate server method implementations and client request calls to use Promises (`async/await` or `.then/.catch`) where appropriate, leveraging the built-in Promise support for cleaner asynchronous code. Note that JSON-RPC errors typically do not reject promises; they are returned in the response object.
Ensure the Jayson server (`server.http().listen(...)` or `server.tcp().listen(...)`) is active and reachable from the client's host and port. Check firewall rules, network configurations, and that the server process is indeed running.
Verify that the client is sending a well-formed JSON-RPC request body, including all required fields (`jsonrpc`, `method`, `params`, `id`). Use a debugging tool or a simple `curl` command to send a minimal valid request to the server to isolate the issue.
Check the method name in the client's `client.request('methodName', ...)` call. Ensure it exactly matches a method name provided in the server's method object (`new jayson.Server({ methodName: function(...) { ... } })`). Case sensitivity matters.Examine the `args` parameter in your server method's definition and compare it to the `params` sent by the client. Ensure the types, number, and structure of arguments match, paying close attention to whether the method expects positional parameters (an array) or named parameters (an object). Add validation to your server methods if input varies.
No dependency data recorded yet.