Expertise technical

Configuring a SMPP connection in Morocco: a step-by-step guide for high-volume

Configuring smpp Morocco: Technical guide with code examples for developers in Morocco.

Configuring a SMPP connection in Morocco: a step-by-step guide for high-volume
Table of Contents
  1. If you are developing the infrastructure of a major Moroccan bank, a major distribution chain or a logistics operator, you will quickly realize that a simple REST API (HTTP) shows its limits.When you have to send 2 million notifications on the day of Id al-Adha, or route vital OTPs at very high volume, the TCP latency of a HTTP request becomes an unacceptable stumbling job.
  2. What exactly is SMPP and for whom?
  3. Connection settings to be configured (The Bind)
  4. Test your connection in a pre-production environment
  5. The most common configuration errors

If you are developing the infrastructure of a major Moroccan bank, a major distribution chain or a logistics operator, you will quickly realize that a simple REST API (HTTP) shows its limits.When you have to send 2 million notifications on the day of Id al-Adha, or route vital OTPs at very high volume, the TCP latency of a HTTP request becomes an unacceptable stumbling job.

The standard solution in the telecom industry is the SMPP (Short Message Peer-to-Peer) protocol.

Although it is extremely fast and asynchronous, setting up a direct SMPP connection with Moroccan gateways requires absolute engineering rigour.

What exactly is SMPP and for whom?

SMPP (currently in v3.4 for most gateways) is a binary protocol running on TCP/IP. Unlike HTTP where you open and close a connection for each sending, SMPP opens a permanent tunnel (a Bind) between your server (ESME) and the provider gateway (SMSC).

What this brings: - Massive Stream: You send a continuous binary stream. No heavy HTTP headers. Throughput is no longer bounded by one HTTP request per message. - Native and asynchronous DLR: Delivery Reports (Delivery Reports) go back from the Moroccan operator (IAM, inwi, Orange) directly into that same TCP tunnel. You no longer need to expose a webhook on your server.

When to use it? The development of a SMPP client takes 10 times more time than an API integration. Use SMPP only if your volume exceeds 1 million SMS per month or if your OTP SLA requires a gateway submission in less than 100 milliseconds.

Connection settings to be configured (The Bind)

To establish an SMPP connection with a gateway that offers one (at EnvoiSMS, SMPP is offered only on request, for high volumes; by default, sending goes through our REST API and its bulk endpoint), your provider will provide you with 4 vital elements: IP, Port, System ID (your login) and Password.

But you need to configure your SMPP client behavior optimally:

  1. The Bind Type:

Transmitter (TX): Only for sending SMS messages.
Receiver (RX): Only for receiving incoming DLRs and SMS.
Transceiver (TRX): The standard recommendation allows you to send and receive on the same TCP connection.

  1. Window Size: This is the secret of the speed of the SMPP. This is the number of messages you can send through the tunnel before waiting for server confirmation (Acknowledge).
  2. The Enquiry Link (Keep-alive): Since the tunnel must remain open 24/7, your script must send an enquiry_link every 30 or 60 seconds to prove to the operator server that you are still online.

Test your connection in a pre-production environment

Never connect directly to the production address. An error loop in your SMPP code can flood the server (unintentional DDoS) and cause your IP to be suspended.

  1. Connect to the provider’s SMPP sandbox.
  2. Send a submit_sm (the request to send a SMS) with a test number (e.g.: +212600000000).
  3. Check the receipt of the submit_sm_resp with a status ESME_ROK (Code 0x00000000), which means that the sending is validated.
  4. Leave your client inactive for 10 minutes to check that your 'enquiry_link' mechanismins the connection without Timeout.

The most common configuration errors

  • Data Coding Scheme (DCS): This is the #1 problem in Morocco. In SMPP, you must explicitly specify the format of your text. For standard French, use DCS 0x00 (SMSC Default) or 0x01 (ASCII). For the Darija with Arabic characters, you must necessarily convert your text to Hexadecimal and set the DCS to 0x08 (UCS-2).
  • The TON/NPI format: For international Moroccan destination numbers (+212), you must configure the TON (Type of Number) to 1 (International) and the NPI (Numbering Plan Indicator) to 1 (ISDN/E.164).
  • Queue Drop: If your TCP connection breaks down, any SMS from your RAM not confirmed by the gateway will be lost.Your client must use an external system such as Redis or RabbitMQ to ensure that any non-"Acké" message is back in line for the next reconnection.

Why choose EnvoiSMS for your business?

Carrier Delivery

Local routes to IAM, Orange and Inwi, with automatic failover between routes and delivery status sent by webhook.

Cost Optimization

WhatsApp Business API from 0.65 MAD per message with optimal ROI.

Sovereign Data (CNDP)

Full compliance with Moroccan personal data protection regulations (CNDP).

How do I track routing on the IAM, Inwi and Orange networks?
Our local routes to Maroc Telecom (IAM), Orange and inwi, with automatic failover between routes, return a carrier delivery status for every message, by webhook. Delivery time depends on the recipient's carrier and network.
How does the platform manage the format of Moroccan numbers?
EnvoiSMS automatically normalizes the numbers entered (06..., 07..., 00212...) to the E.164 standard (+212) to avoid any delivery failure.

Suggested Articles

SMS Formatting in Morocco: Line Breaks, GSM-7 vs UCS-2 Encoding and Cost Optimization
technical

SMS Formatting in Morocco: Line Breaks, GSM-7 vs UCS-2 Encoding and Cost Optimization

WhatsApp Business Formatting in Morocco: Enriched Text, Emojis and Interactive Buttons
technical

WhatsApp Business Formatting in Morocco: Enriched Text, Emojis and Interactive Buttons

One-Tap Autofill & 1-Click WhatsApp OTP Authentication in Morocco
technical

One-Tap Autofill & 1-Click WhatsApp OTP Authentication in Morocco