This project provides a NestJS-based SMPP Gateway that connects to an SMPP server and forwards incoming SMS messages to WebSocket clients in real-time. The gateway supports authentication for WebSocket clients using an API key stored in the environment file.
- SMPP Connectivity: Supports SMPP transceiver mode to send and receive SMS.
- WebSocket Integration: Broadcasts incoming SMS to all connected WebSocket clients.
- Secure Authentication: Clients must provide an API key to establish a WebSocket connection.
- Reconnection Handling: Automatically reconnects to the SMPP server if the connection is lost.
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install dependencies:
npm install
-
Set up the environment variables by creating a
.envfile:API_KEY=your_websocket_api_key SMPP_HOST=192.168.1.60 SMPP_PORT=2775 SMPP_USER={username} SMPP_PASS={password}
-
Run the application:
npm run start
The SMPP Gateway connects to an SMPP server and listens for incoming SMS. When a message is received, it broadcasts the SMS details to all authenticated WebSocket clients.
Clients connect to the WebSocket server by providing the API key as a query parameter. Incoming messages are forwarded to clients in real-time.
ws://<your-server-address>:<port>?apiKey=your_api_key
const socket = io('http://localhost:3000', {
query: {
apiKey: 'your_api_key',
},
});
socket.on('connect', () => {
console.log('Connected to WebSocket server');
});
socket.on('sms', (data) => {
console.log('Received SMS:', data);
});Incoming SMS messages from the SMPP server are broadcasted to WebSocket clients as:
{
"source": "<source-address>",
"destination": "<destination-address>",
"message": "<message-content>",
"timestamp": "<timestamp>"
}-
GOIP Configuration
- Log in to the GOIP device's admin panel.
- Navigate to the SMS Settings or SMPP Configuration section.
- Configure the following parameters:
- SMPP Server Address: IP of the server running the SMPP Gateway.
- SMPP Port: Port of the SMPP Gateway (default: 2775).
- System ID:
username(as configured in.env). - Password:
password(as configured in.env).
-
Send SMS Using GOIP
- Send an SMS through the GOIP device. The SMS will be forwarded to the SMPP Gateway and broadcasted to WebSocket clients.
-
Receive SMS on WebSocket Client
- Connect a WebSocket client to the server.
- Use the example JavaScript client provided above to receive SMS messages in real-time.
Handles SMPP server connection and processes incoming SMS messages.
Manages WebSocket connections and broadcasts messages to connected clients.
This project is licensed under the MIT License.