onlinecity / php-smpp

PHP 5 based SMPP client library
232 stars 161 forks source link

Getting SMS from SMPP takes ages to finish #43

Closed gelinger777 closed 9 years ago

gelinger777 commented 9 years ago

Hi there, I am trying to get the messages from the SMPP server . The sending part works like a charm, but when I try to get messages like this

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'smppclient.class.php';
require_once 'sockettransport.class.php';
require_once 'gsmencoder.class.php';

// Construct transport and client
$transport = new SocketTransport(array('SMPPIP'),3333);
#die("cheee");

$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data
$smpp = new SmppClient($transport);

// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;

// Open the connection
$transport->open();
$smpp->bindTransmitter("Login","Pass");

// Read SMS and output
$sms = $smpp->readSMS();
echo "SMS:\n";
var_dump($sms);

// Close connection
$smpp->close();

?>

The page dont load very long, despite even the fact i am putting the timout small 60 instead of 60000.

It never loads. I had feeling that connection is somehow stays and I have to restart apache so that Kannel can again connect to SMPP. I need just simply get the Messages.

What can be the reason?

cypres commented 9 years ago

Please see these two new entries to the FAQ

Can I use this to send messages from my website?
Not on it's own, no. After PHP processes the request on a website, it closes all connections. Most SMPP providers do not want you to open and close connections, you should keep them alive and send enquire_link commands periodically. Which means you probably need to get some kind of long running process, ie. using the process control functions, and implement a form of queue system which you can push to from the website. This requires shell level access to the server, and knowledge of unix processes.

How do I receive delivery receipts or SMS'es?
To receive a delivery receipt or a SMS you must connect a receiver in addition to the transmitter. This receiver must wait for a delivery receipt to arrive, which means you probably need to use the process control functions.

We do have an open source implementation at php-smpp-worker you can look at for inspiration, but we cannot help you with making your own. Perhaps you should look into if your SMSC provider can give you a HTTP based API or using turnkey software such as kannel, this project provides the protocol implementation only and a basic socket wrapper.