Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simple implementation of Remote Procedure Call (RPC) in Node.js. This project demonstrates inter-process communication between a client and server using HTTP POST requests with JSON payloads. Designed for learning and experimentation, especially when hosted across different machines or networks (e.g., using Ngrok).

Notifications You must be signed in to change notification settings

FarhanTausif/RPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🌐 RPC with Node.js

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.

📁 Project Structure

RPC/
├── RPC-server/
│   ├── rpc-server.js
│   └── package.json
├── RPC-client/
│   ├── rpc-client.js
│   └── package.json

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/FarhanTausif/RPC.git
cd RPC

🖥️ Server Setup

🔧 Install Dependencies

cd RPC-server
npm install express body-parser dotenv ngrok 

▶️ Start the Server

node rpc-server.js

By default, the server runs at:
http://localhost:3000/rpc

If you're running across different networks, use Ngrok:

ngrok http 3000

Use the HTTPS forwarding URL from Ngrok (e.g., https://abc123.ngrok-free.app) in your client.


💻 Client Setup

🔧 Install Dependencies

cd RPC-client
npm install

📝 Update RPC URL in rpc-client.js

const SERVER_URL = "<server_ip_address>/rpc"; // Or your ngrok HTTPS URL

▶️ Run the Client

node rpc-client.js

🧪 Sample RPC Request

The client sends a JSON request like:

{
  "method": "add",
  "params": [5, 3]
}

And the server responds with:

{
  "result": 8
}

🧰 Technologies Used

  • Node.js
  • Express.js
  • Axios
  • Ngrok (optional for tunneling)
  • body-parser
  • dotenv

About

Simple implementation of Remote Procedure Call (RPC) in Node.js. This project demonstrates inter-process communication between a client and server using HTTP POST requests with JSON payloads. Designed for learning and experimentation, especially when hosted across different machines or networks (e.g., using Ngrok).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •