简体   繁体   中英

Persistent socket/connection PHP for SMPP/SMS

I need to set up a persistent socket connection in PHP and not sure how to achieve this. Currently when I send an SMS message I a) open a socket connection b) send a message (via SMS/SMPP) and c) close the socket connection

however I need to not open and close the connection all the time. Rather, I require

- 2 persistent connections that maintains connectivity to an SMSC (SMS centre) and reconnects when a timeout occurs. 
- One persistent connection for reading SMS and one for sending SMS.
- Automatic restart/recovery (i.e. when memory issues arise)
- Automatic looping to act as listener for incoming events such as receiving incoming delivery receipts and sms messages, as well as 'ping' (enquire link) to keep SMPP connection alive.

UPDATE: Was wondering if anyone had achieved the above using the following: https://github.com/shaneharter/PHP-Daemon

Function pfsockopen seems to have capabilities you are looking for. Check out this question - PHP pfsockopen in a session .

===

A personal observation on your implementation. I am assuming that PHP code will be triggered by an incoming request and all other times, SMPP client will be inactive. This may not be quite suitable for SMPP for few reasons:

  • SMPP clients are required to send back response PDU(s) for all the inbound PDU they receive from SMSC.
  • One of these PDU(s) is enquire_link which is used to keep a connection alive. If a SMPP client fails to return enquire_link_resp PDU, the connection will be dropped. You may experience more of these. Using pfsockopen will not solve this problem.
  • If you want to offer delivery confirmation, the SMPP client must respond to the SMSC.
  • If a SMPP client fails to send response PDU for the PDU it recieves for SMSC (if it reads the bytes from the pipe), the SMSC may resend some of those PDU(s). This opens up possible risks of creating unnecessary hit on the SMPP client machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM