Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: John Howland <jch at iron dot wi dot mit dot edu>
Subject: where is ct_connect timeout set?
Date: Nov 26 1997 5:54PM

Ladies nad Gentlemen:

Please be kind enough to point me toward the documentation
or FAQ that describes an
	"internal Client Library error: Read from the server has timed out"

I get this error on my very first ct_connect in the morning.

When I re-run my little test program immediately after the failure,
the program works.

Points I need help on are
	1. Can I reset the timeout value, and if so, how

	2. How can I reliably detect this condition and what
	   suggestions do you have for a re-try strategy


	I imagine that Sybase is swapped out, due to inactivity.

	The connect fails while waiting for Sybase to get
	its working set into main memory

	On running the program again, the connect succeeds because
	Sybase is swapped in and can reply without delay.

Test Case:

	I can detect this problem using the sample program
	from the SybPerl html manual

Thank you,

John Howland
Whitehead/MIT Center for Genome Research


yes, I have spent several days pouring through the manuals
and trying to decipher code.

-------- cut here on any replies -----------

Test Results

First execution

Open Client Message:
Message number: LAYER = (1) ORIGIN = (2) SEVERITY = (2) NUMBER = (63)
Message String: ct_connect(): user api layer: internal Client Library error: Read from the server has timed out.
ct_connect failed at line 20.
Can't call method "ct_execute" without a package or object reference at line 25.

Second execcution immediately after

Server message: (In srv_cb)
Message number: 5701, Severity 10, State 2, Line 0
Message String: Changed database context to 'seq'.

select * from jc_Gel
ID      Name
4       foo
5       fum
6       fi
7       chad
End of Results Sets

The Program


use Sybase::CTlib;

ct_callback(CS_CLIENTMSG_CB, &msg_cb);
ct_callback(CS_SERVERMSG_CB, "srv_cb");

$uid  = getpwuid($<);

$pwd = 'my_sybase_password';
$srv = '';

$X = Sybase::CTlib->ct_connect($uid, $pwd, $srv);

$X->ct_execute("select * from jc_Gel");

while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
    next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
            $restype == CS_CMD_SUCCEED);

    if(@names = $X->ct_col_names()) {
	$x = shift (@names);
	print $x;
	while ($x = shift (@names)) {
	    print "\t$x";

        print "\n";

    while(@dat = $X->ct_fetch) {
	 $x = shift (@dat);
	 print $x;
	 while ($x = shift (@dat) ) {
	     print "\t$x";

         print "\n";

print "End of Results Sets\n" if($rc == CS_END_RESULTS);
print "Error!\n" if($rc == CS_FAIL);

sub msg_cb {
    my($layer, $origin, $severity, $number, $msg, $osmsg) = @_;

    if ($severity != 0) {

	printf STDERR "\nOpen Client Message: (In msg_cb)\n";
	printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
	       $layer, $origin;
	printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n",
	       $severity, $number;
	printf STDERR "Message String: %s\n", $msg;
	if (defined($osmsg)) {
	    printf STDERR "Operating System Error: %s\n", $osmsg;

sub srv_cb {
    my($cmd, $number, $severity, $state, $line, $server,
       $proc, $msg) = @_;

    printf STDERR "\nServer message: (In srv_cb)\n";
    printf STDERR "Message number: %ld, Severity %ld, ",
           $number, $severity;
    printf STDERR "State %ld, Line %ld\n", $state, $line;

    if (defined($server)) {
        printf STDERR "Server '%s'\n", $server;

    if (defined($proc)) {
        printf STDERR " Procedure '%s'\n", $proc;

    printf STDERR "Message String: %s\n", $msg;