A simple Remote Procedure Call (RPC) implementation using Node.js, Express, and Axios. This project demonstrates how to perform RPC communication between a client and a server over HTTP using JSON, either on the same network or via tunnels like Ngrok.
RPC/
├── RPC-server/
│ ├── rpc-server.js
│ └── package.json
├── RPC-client/
│ ├── rpc-client.js
│ └── package.json
git clone https://github.com/FarhanTausif/RPC.git
cd RPCcd RPC-server
npm install express body-parser dotenv ngrok node rpc-server.jsBy default, the server runs at:
http://localhost:3000/rpc
If you're running across different networks, use Ngrok:
ngrok http 3000Use the HTTPS forwarding URL from Ngrok (e.g., https://abc123.ngrok-free.app) in your client.
cd RPC-client
npm installconst SERVER_URL = "<server_ip_address>/rpc"; // Or your ngrok HTTPS URLnode rpc-client.jsThe client sends a JSON request like:
{
"method": "add",
"params": [5, 3]
}And the server responds with:
{
"result": 8
}- Node.js
- Express.js
- Axios
- Ngrok (optional for tunneling)
- body-parser
- dotenv