onlinecity / php-smpp

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

ENQUIRE_LINK_RESP PDU should not have body #49

Open ritmas opened 9 years ago

ritmas commented 9 years ago

ENQUIRE_LINK_RESP PDU body length is 1 character longer than expected. Currently it's used as follows:

SmppPdu(SMPP::ENQUIRE_LINK_RESP, SMPP::ESME_ROK, $pdu->sequence, "\x00");

but strlen("\x00") = 1 and according to SMPP 3.4 (p. 106) only header must be sent, without body.

I've stumbled on this lately while establishing connection with as I assume strictly configured SMSC (not sure). Upon sending response to ENQUIRE_LINK I was keep getting generick nack:

command id : 0x80000000
command status : 0x2 Command Length is invalid

Once I truncated PDU body issue's gone.

SmppPdu(SMPP::ENQUIRE_LINK_RESP, SMPP::ESME_ROK, $pdu->sequence, "");
funnygod commented 8 years ago

Same here

atuladcan commented 6 years ago

How to keep sessions alive in smpp after sending sms.

require_once 'smppclient.class.php'; require_once 'gsmencoder.class.php'; require_once 'sockettransport.class.php';

// Construct transport and client

$transport = new SocketTransport(array(''),); $transport->setSendTimeout(100000);

// Open the connection $transport->open();

$smpp = new SmppClient($transport);

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

$smpp->bindTransmitter("","");

// Optional connection specific overrides //SmppClient::$sms_null_terminate_octetstrings = false; //SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD; //SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;

// Prepare message

for($i = 0; $i < 2; $i++){

$mobile   = "";
$message  = "msg";
$senderid = "";

$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress($senderid,SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress("91".$mobile,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
$tags = array();

// Send
if($sm = $smpp->sendSMS($from,$to,$encodedMessage, $tags)){
    echo $sm;
    echo "Msg Sent<br/>";

}

}

$vv = $smpp->enquireLink();

print_r($vv);

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