I am trying to send a SMPP message using the Net::SMPP module, but it's giving the error below:
Message state is 2
Response indicated error: Message ID is invalid (ESME_RINVMSGID=0x0000000C) at send.pl line 28.
#!/usr/bin/perl
#use strict;
#use warnings;
use Net::SMPP;
my $host = 'iphost';
my $port = 2345;
my $smpp = Net::SMPP->new_transmitter(
$host,
port => $port,
system_id => 'username',
password => 'pass',
) or die;
$resp_pdu = $smpp->submit_sm(
destination_addr => '+44206064379',
short_message => 'test message'
) or die;
die "Response indicated error: " . $resp_pdu->explain_status()
if $resp_pdu->status;
$msg_id = $resp_pdu->{message_id};
$resp_pdu = $smpp->query_sm(message_id => $msg_id) or die;
die "Response indicated error: " . $resp_pdu->explain_status()
if $resp_pdu->status;
print "Message state is $resp_pdu->{message_state}\n";
$resp_pdu = $smpp->replace_sm(
message_id => $msg_id,
short_message => 'another test'
) or die;
die "Response indicated error: " . $resp_pdu->explain_status()
if $resp_pdu->status;
$resp_pdu = $smpp->cancel_sm(message_id => $msg_id) or die;
die "Response indicated error: " . $resp_pdu->explain_status()
if $resp_pdu->status;
If you are trying to send a message then you are succeeding. The message is sent using the submit_sm method.
The first line of the output is showing the result from the query_sm, which returns the state of the message. The state 2 corresponds to a status of DELIVERED (from SMPP v3.4 spec). This means the SMSC has delivered the message to the mobile device.
The error is being generated by the replace_sm method. The replace_sm method will only replace a message that is still on the SMSC, i.e. still awaiting delivery. If the message is already delivered, the SMSC returns an error in the response PDU. The same thing applies to the cancel_sm method. It only works on messages that are still awaiting delivery.