If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > NET::SMPP.pm error on connection lost

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-08, 04:08
exceter exceter is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
Angry 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();
};
Reply With Quote
  #2 (permalink)  
Old 04-12-09, 07:53
Fugsscuccub Fugsscuccub is offline
Registered User
 
Join Date: Apr 2009
Posts: 1
important information to all

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On