Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    6
    Rep Power
    0

    Using NET::SMPP as receiver (from mobile to ESME)


    Hi All,
    i would like to use NET::SMPP package in perl script to act as receiver (receiving sms from mobile )
    any help please
    thanks in advance
  2. #2
  3. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    You just bind as receiver and that's it - docs and examples included with the module are good enough IMHO.

    Give some specific questions if you want specific answer...

    PS. BTW what service provider were you thinking on using, in what country will the numbers be and what is the the price - I might be able to provide a better deal - send me a private msg or via IM.
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    6
    Rep Power
    0
    Hi,
    thanks for your response.
    more specifically, i would to know how to keep connection between ESME<-->Operator SMSC opened permanently to receive SMS from Mobile 24h/24
    i think that "bind receiver" will open the connection once, not more than that
    any suggestion ?
    thanks in advance
  6. #4
  7. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    No - you bind_receiver (which means connect + "login" as receiver) once, and stay connected. This is all you basically need: http://cpansearch.perl.org/src/SAMPO...12/esme-rec.pl

    Perhaps a bit more code in that while(1) block to check if connection has been lost, so it would reconnect. And obviously add some code into the part "0x80000005 => { cmd => 'deliver_sm_resp', reply => undef, }, # *** need to handle this?" that will store and process the messages you receive.
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    6
    Rep Power
    0
    thanks a lot
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    6
    Rep Power
    0
    Hi,
    when testing the script "esme-rec.pl"
    the bind_receiver was successful but i got the following error
    premature eof reading from socket at /usr/local/lib/perl5..../SMPP.pm line 2346
    Not a hash reference at /usr/local/.../SMPP.pm line 2347

    any idea ?
  12. #7
  13. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    That usually means the other side closed the connection - either intentionally or more likely due to some error.
    Last edited by techcode; May 26th, 2009 at 08:40 AM.
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    6
    Rep Power
    0
    so any suggestion ? any workaround or tests ?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Using NET::SMPP to send a message


    Originally Posted by techcode
    That usually means the other side closed the connection - either intentionally or more likely due to some error.
    I was using Net::SMPP to send sms fine, I left the company and now I am back, in the mean while they've changed the SMSC when I use one of my previouse scripts I get a status of 11:
    use Net::SMPP;

    use Data:umper;

    $trace = 0;

    $Net::SMPP::trace = 0;

    $sysid = "xxxxxxx";

    $pw = "xxxx";

    $host = '10.xxxx.0.xxx';

    $port = xxxxx;

    $facil = 0x00010003; # NF_PDC | GF_PVCY

    my $msgtxt = "is a test from perl";

    my $number ="+xxxxxxxxxx";

    $vers = 0x34;

    $if_vers = 0x00;

    $ref = 160;

    $msgref = sprintf "%.8d", $ref;

    #($smpp, $resp) = Net::SMPP->new_transmitter($host,

    ($smpp, $resp) = Net::SMPP->new_transceiver($host,

    smpp_version => $vers,

    interface_version => $if_vers,

    system_id => $sysid,

    password => $pw,

    addr_ton => 0x01,

    addr_npi => 0x01,

    source_addr_ton => 0x00,

    source_addr_npi => 0x00,

    dest_addr_ton => 0x01,

    dest_addr_npi => 0x01,

    system_type => '_001',

    facilities_mask => $facil,

    port => $port,

    )

    or die "Can't contact server: $!";

    $resp2 = $smpp->submit_sm(

    protocol_id=>0x20, # telematic_interworking

    validity_period=>0, # "default"

    source_addr_ton => 0x00,

    source_addr => '',

    esm_class =>($multimsg_curpart?0x40:0x00),

    destination_addr => '+218912120387',

    data_coding => 0x08,

    short_message=>'Hello world',

    PDC_MessageClass => "\x20\x00",

    PDC_PresentationOption => "\x01\xff\xff\xff",

    PDC_AlertMechanism => "\x01",

    PDC_Teleservice => "\x04",

    PDC_PredefinedMsg => "\0",

    PVCY_AuthenticationStr => "\x01\x00\x00",

    source_subaddress => "\x01\x00\x00", # PDC_Originator_Subaddr

    dest_subaddress => "\x01\x00\x00" # PDC_Destination_Subaddr

    );



    $resp = $smpp->unbind();

    warn Dumper $resp;

    warn Dumper $resp2;



    $VAR1 = bless( {

    'known_pdu' => 1,

    'cmd' => 2147483654,

    'status' => 0,

    'data' => '',

    'reserved' => undef,

    'seq' => 3

    }, 'Net::SMPP::PDU' );

    $VAR1 = bless( {

    'known_pdu' => 1,

    'message_id' => '0',

    'cmd' => 2147483652,

    'status' => 11,
    'data' => '0',

    'reserved' => undef,

    'seq' => 2

    }, 'Net::SMPP::PDU' );
  18. #10
  19. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    First of all - use code tags for posting code.

    Second - you should really get yourself SMPP specification - error/status code 11 means 'Invalid destination address'.

    I've seen loads of SMSC's and each one has it's own little rules about different things. Some (well most if not all as I can't remember the one that does) don't accept + in front of destination number. So try with just '218912120387'. Some do accept 00 instead of + though - so try that as well.

    Where I work - we don't use most of those parameters you have in submit_sm call - just the basics - source, destination, ston, snpi, dton/dnpi (always 1/1 as destination must be in international format), dcs and message of course.

    PS. I believe interworking sms's are quite expensive?
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Coming across an error


    Hi,

    I'm trying to the same as stated in the original post; receive text messages from a server and store them into a database. I tried running esme-rec.pl but come across the following error:
    "Can't call method "bind_receiver" on an undefined value at Net/SMPP.pm line 2203." What does this mean?

    Also when defining the response, how can I store the incoming message in a MySQL database? so far I have the following code for inserting a row into the database:

    my $mysql = Net::MySQL->new(
    hostname => $host,
    database => $database,
    user => $user,
    password => $password,
    );
    $mysql->query(q{
    INSERT INTO tablename (first, last) VALUES ('John', 'Smith)
    });
    printf "Affected row: %d\n", $mysql->get_affected_rows_length;

    $mysql->close;

    Originally Posted by techcode
    No - you bind_receiver (which means connect + "login" as receiver) once, and stay connected. This is all you basically need:

    Perhaps a bit more code in that while(1) block to check if connection has been lost, so it would reconnect. And obviously add some code into the part "0x80000005 => { cmd => 'deliver_sm_resp', reply => undef, }, # *** need to handle this?" that will store and process the messages you receive.
  22. #12
  23. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    "Can't call method "bind_receiver" on an undefined value at Net/SMPP.pm line 2203." What does this mean?
    It probably means you have wrong username/password/ip/network problem/etc - well it can be a lot of things. Try turning on the debug/trace mode with:
    Code:
    use Net::SMPP;
    $Net::SMPP::trace = 1;
    ...
    Also try some more debugging with something like:
    Code:
    ($smpp, $resp)=Net::SMPP->new_receiver(
    			$host,
    			interface_version	=> $if_vers,
    			password		=> $pw,
    			port			=> $port,
    			system_id		=> $sysid,
    			addr_ton		=> 1,
    			addr_npi		=> 1,
    			system_type		=> $system_type,
    			bind			=> $bind_address,
    			async			=> 1,
    		);
    
    use Data::Dumper;
    print Dumper($smpp, $resp);
    Seems like you have a lot to learn about programming in Perl - in general, not just SMPP stuff - but you came to the right place

    Read up on Data:umper, and DBI - you should use prepared statements for working with DB's.
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0
    Thanks for the timely response; you are right I have ways to go before becoming an expert in Perl!

    I turned on tracing and used Data:umper but still get the same error and no extra debugging information.
    As for username/password/ip/network problems that can't be true as when I run smsc.pl with the same values I'm able to receive messages and the smsc.pl responds to them successfully.

    I wrote a simple script that accesses the data base and stores the information into MySQL, can't I just integrate that into the smsc file that handles the incoming submit_sm? I'd appreciate if you could supply a sample code as to how the Data:umper could work. I looked at the documentation but not sure this can be used to store information onto a database!

    Thanks again

    Originally Posted by techcode
    It probably means you have wrong username/password/ip/network problem/etc - well it can be a lot of things. Try turning on the debug/trace mode with:
    Code:
    use Net::SMPP;
    $Net::SMPP::trace = 1;
    ...
    Also try some more debugging with something like:
    Code:
    ($smpp, $resp)=Net::SMPP->new_receiver(
    			$host,
    			interface_version	=> $if_vers,
    			password		=> $pw,
    			port			=> $port,
    			system_id		=> $sysid,
    			addr_ton		=> 1,
    			addr_npi		=> 1,
    			system_type		=> $system_type,
    			bind			=> $bind_address,
    			async			=> 1,
    		);
    
    use Data::Dumper;
    print Dumper($smpp, $resp);
    Seems like you have a lot to learn about programming in Perl - in general, not just SMPP stuff - but you came to the right place

    Read up on Data:umper, and DBI - you should use prepared statements for working with DB's.
  26. #14
  27. Guru Meditation
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Amsterdam
    Posts
    1,304
    Rep Power
    382
    You use Data:umper to print out data structures (modules/objects) to help you while trying to debug.

    You first talked about receiver client connection - and you are now mentioning SMSC? So I don't get it what's going on?
    www.booking.com is hiring Perl developers!
    Work along some of the biggest names in Perl community. Live in Amsterdam - relocation assistance is provided (paperwork/visa and financial) for you and your family members - for details send me an message

  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0
    Ok I'd misread your previous post; you were recommending that I use Data:umper as a debugging tool but not to update the database!

    To clarify, I'm receiving SMS messages from a mobile and want to run ESME in a receiving mode. Then when the message is received I want to store the message, including it's content into a MySQL database. Should the code accessing the database be in a reply to a submit_sm or delivery_sm and why?

    Thanks

    Originally Posted by techcode
    You use Data:umper to print out data structures (modules/objects) to help you while trying to debug.

    You first talked about receiver client connection - and you are now mentioning SMSC? So I don't get it what's going on?
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo