Set connection timeout in Perl?

353 views
Skip to first unread message

Fireproofsocks

unread,
Jul 30, 2010, 12:27:11 PM7/30/10
to mongodb-user
I've looked at this thread: http://groups.google.com/group/mongodb-user/browse_thread/thread/186327738ae67085

I'm running a command-line Perl script that consistently gets an
error:

recv timed out at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-
multi/MongoDB/Cursor.pm line 231.

MongoDB shell version: 1.4.3
Perl MongoDB version: 0.34

This is driving me nuts. Any pointers?

Kristina Chodorow

unread,
Jul 30, 2010, 12:38:34 PM7/30/10
to mongod...@googlegroups.com
You can turn off the timeout by setting it to -1.



--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Fireproofsocks

unread,
Jul 30, 2010, 1:00:17 PM7/30/10
to mongodb-user
Sorry to be completely dense, but how?

Here's what I've tried:

my $conn = MongoDB::Connection->new;
MongoDB::Connection::timeout = 90000; # this fails.
$conn->query_timeout = 90000; # this fails too.
my $db = $conn->get_database('mydb');
my $domain_coll = $db->get_collection('mycollection');

Thanks.

On Jul 30, 9:38 am, Kristina Chodorow <krist...@10gen.com> wrote:
> You can turn off the timeout by setting it to -1.
>
> On Fri, Jul 30, 2010 at 12:27 PM, Fireproofsocks
> <fireproofso...@gmail.com>wrote:
>
>
>
> > I've looked at this thread:
> >http://groups.google.com/group/mongodb-user/browse_thread/thread/1863...
>
> > I'm running a command-line Perl script that consistently gets an
> > error:
>
> > recv timed out at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-
> > multi/MongoDB/Cursor.pm line 231.
>
> > MongoDB shell version: 1.4.3
> > Perl MongoDB version: 0.34
>
> > This is driving me nuts.  Any pointers?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mongodb-user...@googlegroups.com<mongodb-user%2Bunsubscribe@google groups.com>
> > .

Kristina Chodorow

unread,
Jul 30, 2010, 1:09:38 PM7/30/10
to mongod...@googlegroups.com
query_timeout is an attribute, so you can set it like:

my $conn = MongoDB::Connection->new(query_timeout => 90000);

or

$conn->query_timeout(90000);

I'll add an example to the documentation.


To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.

Fireproofsocks

unread,
Jul 30, 2010, 1:14:00 PM7/30/10
to mongodb-user
Thanks! Sorry I'm so dense... I was looking like crazy for an example
and couldn't figure out why I was getting an error:
"Can't modify non-lvalue subroutine call in scalar assignment"



On Jul 30, 10:09 am, Kristina Chodorow <krist...@10gen.com> wrote:
> query_timeout is an attribute, so you can set it like:
>
> my $conn = MongoDB::Connection->new(query_timeout => 90000);
>
> or
>
> $conn->query_timeout(90000);
>
> I'll add an example to the documentation.
>

Kristina Chodorow

unread,
Jul 30, 2010, 1:22:07 PM7/30/10
to mongod...@googlegroups.com
No problem, I always do that, too :)

Also, MongoDB::Connection::timeout will be inherited by query_timeout, but only if you call it before creating the connection:

$MongoDB::Connection::timeout = 90000;

my $conn = MongoDB::Connection->new;



To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.

Graham Barr

unread,
Jul 30, 2010, 2:38:52 PM7/30/10
to mongod...@googlegroups.com
On Jul 30, 2010, at 12:22 PM, Kristina Chodorow wrote:

No problem, I always do that, too :)

Also, MongoDB::Connection::timeout will be inherited by query_timeout, but only if you call it before creating the connection:

you mean $MongoDB::Cursor::timeout

Graham.

Kristina Chodorow

unread,
Jul 30, 2010, 2:40:31 PM7/30/10
to mongod...@googlegroups.com
Yes, thanks.
Reply all
Reply to author
Forward
0 new messages