Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 05: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
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

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