Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    5

    Angry Unanswered: NET::SMPP.pm error on connection lost

    Hi,

    I have a transreceiver program in perl, connects to SMSC over SMPP protocol.
    actually it works good, but the problem occurs when the connection is lost
    stats giving this error and does not disconnect:
    Generick nack pdu: $VAR1 = {};
    premature eof reading from socket at Net/SMPP.pm line 2347.

    what I am doing wrong? how to make it so that when the disconnection is lost, just try to reconnect. here is my code:

    while (1) { #цикл создающий сессии
    $bCanLoop = 0;
    ConnectSMPP();
    my $lastEnqTime = time;
    my $conterForDeleteFiles = 0;
    warn "Next try to connect.";
    if (!defined($smpp)){
    warn "Connection failed.";
    sleep 3;
    next;
    };
    #if ($bCanLoop){
    # $t = threads->new(\&Enquire_thread);
    # warn "Connection established.";
    #};
    while ($bCanLoop){ # цикл чтения котроля в разрезе одной сессси
    if (!defined($smpp->connected())){
    warn "Connection lost.";
    $bCanLoop = 0;
    last; # прекращаем работу - сокета у нас почему то нет...
    };
    my $client;
    my $wait_flag = 1;
    # сеция для чтения
    foreach $client ($select->can_read(2)){
    $wait_flag = 0;
    eval {
    # чтение из соединения
    my $pdu = $smpp->read_pdu();
    ParsePdu($pdu);
    };
    if ($@) {
    warn "Error on reading, Connection lost - waiting child: $@";
    $bCanLoop = 0;
    #if (defined($t)){
    # $t->join();
    #};
    last; # прекращаем работу - сокета нет
    };
    };
    # section for ENQUIRE_LINK
    if ((time - $lastEnqTime) > 2){
    $conterForDeleteFiles++;
    if (!defined($smpp->connected())){
    warn "Connection lost (Enquire_thread) - closing child.";
    last; # socked failed - end of loop
    };
    eval {
    foreach $client ($select->can_write(0.5)) {
    $smpp->enquire_link('async');
    $lastEnqTime = time;
    };
    };
    if ($@) {
    warn "Error on writing, Connection lost - closing child: $@";
    $bCanLoop = 0;
    last; # прекращаем работу - сокета нет
    };
    if ($conterForDeleteFiles > 10){
    $conterForDeleteFiles > 0;
    };
    #SpamSender();
    };
    };
    DisconnectSMPP();
    };

  2. #2
    Join Date
    Apr 2009
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •