You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Vivek Goel <go...@gmail.com> on 2013/03/13 19:49:27 UTC

Recv timeout not working

I am using thrift C++ library at  both end  server and client.

I am facing problem with recv timeout. I am setting a one hour value for
recv timeout. But it is not working, clients are infinitely waiting on
server restart.


My code is:
----------------------------------------------------------------------------------------
boost::shared_ptr<TSocket> socket = boost::shared_ptr<TSocket>(
        new TSocket(server_host_, server_port_));
    socket->setConnTimeout(ThriftConf::connection_timeout_);
    socket->setRecvTimeout(ThriftConf::recv_timeout_);
    socket->setSendTimeout(ThriftConf::send_timeout_);
    boost::shared_ptr<TTransport> tr =
boost::shared_ptr<TBufferedTransport>(
        new TBufferedTransport(socket));
    boost::shared_ptr<TBinaryProtocol> p =
boost::shared_ptr<TBinaryProtocol>(
        new TBinaryProtocol(tr));

----------------------------------------------------------------------------------------------------

Where values are:
(gdb) print ThriftConf::connection_timeout_
$1 = 360000
(gdb) print ThriftConf::recv_timeout_
$2 = 3600000
(gdb) print ThriftConf::send_timeout_
$3 = 180000


regards
Vivek Goel

Re: Recv timeout not working

Posted by Ben Craig <be...@ni.com>.
I don't think there is a function for it on TSocket right now.  What you 
can do is call getSocketFD(), and then do something similar to the 
following with the result:

   int optval = 1;
   socklen_t optlen = sizeof(optval);
   setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen);



From:   Vivek Goel <go...@gmail.com>
To:     user@thrift.apache.org, 
Date:   03/15/2013 01:02 AM
Subject:        Re: Recv timeout not working



Can you please tell how can I enable it?
I didn't find any property for class TSocket.

regards
Vivek Goel


On Thu, Mar 14, 2013 at 1:10 AM, Ben Craig <be...@ni.com> wrote:

> I think I've heard of this problem before, and I think the fix was to 
turn
> on keep alive.  I don't think there are existing hooks for that in 
thrift
> though.  Turning on keepalive should also make your clients throw an
> exception much faster than one hour.
>
>
>
> From:   Vivek Goel <go...@gmail.com>
> To:     user@thrift.apache.org,
> Date:   03/13/2013 01:50 PM
> Subject:        Recv timeout not working
>
>
>
> I am using thrift C++ library at  both end  server and client.
>
> I am facing problem with recv timeout. I am setting a one hour value for
> recv timeout. But it is not working, clients are infinitely waiting on
> server restart.
>
>
> My code is:
>
> 
----------------------------------------------------------------------------------------
> boost::shared_ptr<TSocket> socket = boost::shared_ptr<TSocket>(
>         new TSocket(server_host_, server_port_));
>     socket->setConnTimeout(ThriftConf::connection_timeout_);
>     socket->setRecvTimeout(ThriftConf::recv_timeout_);
>     socket->setSendTimeout(ThriftConf::send_timeout_);
>     boost::shared_ptr<TTransport> tr =
> boost::shared_ptr<TBufferedTransport>(
>         new TBufferedTransport(socket));
>     boost::shared_ptr<TBinaryProtocol> p =
> boost::shared_ptr<TBinaryProtocol>(
>         new TBinaryProtocol(tr));
>
>
> 
----------------------------------------------------------------------------------------------------
>
> Where values are:
> (gdb) print ThriftConf::connection_timeout_
> $1 = 360000
> (gdb) print ThriftConf::recv_timeout_
> $2 = 3600000
> (gdb) print ThriftConf::send_timeout_
> $3 = 180000
>
>
> regards
> Vivek Goel
>
>


Re: Recv timeout not working

Posted by Vivek Goel <go...@gmail.com>.
Can you please tell how can I enable it?
I didn't find any property for class TSocket.

regards
Vivek Goel


On Thu, Mar 14, 2013 at 1:10 AM, Ben Craig <be...@ni.com> wrote:

> I think I've heard of this problem before, and I think the fix was to turn
> on keep alive.  I don't think there are existing hooks for that in thrift
> though.  Turning on keepalive should also make your clients throw an
> exception much faster than one hour.
>
>
>
> From:   Vivek Goel <go...@gmail.com>
> To:     user@thrift.apache.org,
> Date:   03/13/2013 01:50 PM
> Subject:        Recv timeout not working
>
>
>
> I am using thrift C++ library at  both end  server and client.
>
> I am facing problem with recv timeout. I am setting a one hour value for
> recv timeout. But it is not working, clients are infinitely waiting on
> server restart.
>
>
> My code is:
>
> ----------------------------------------------------------------------------------------
> boost::shared_ptr<TSocket> socket = boost::shared_ptr<TSocket>(
>         new TSocket(server_host_, server_port_));
>     socket->setConnTimeout(ThriftConf::connection_timeout_);
>     socket->setRecvTimeout(ThriftConf::recv_timeout_);
>     socket->setSendTimeout(ThriftConf::send_timeout_);
>     boost::shared_ptr<TTransport> tr =
> boost::shared_ptr<TBufferedTransport>(
>         new TBufferedTransport(socket));
>     boost::shared_ptr<TBinaryProtocol> p =
> boost::shared_ptr<TBinaryProtocol>(
>         new TBinaryProtocol(tr));
>
>
> ----------------------------------------------------------------------------------------------------
>
> Where values are:
> (gdb) print ThriftConf::connection_timeout_
> $1 = 360000
> (gdb) print ThriftConf::recv_timeout_
> $2 = 3600000
> (gdb) print ThriftConf::send_timeout_
> $3 = 180000
>
>
> regards
> Vivek Goel
>
>

Re: Recv timeout not working

Posted by Ben Craig <be...@ni.com>.
I think I've heard of this problem before, and I think the fix was to turn 
on keep alive.  I don't think there are existing hooks for that in thrift 
though.  Turning on keepalive should also make your clients throw an 
exception much faster than one hour.



From:   Vivek Goel <go...@gmail.com>
To:     user@thrift.apache.org, 
Date:   03/13/2013 01:50 PM
Subject:        Recv timeout not working



I am using thrift C++ library at  both end  server and client.

I am facing problem with recv timeout. I am setting a one hour value for
recv timeout. But it is not working, clients are infinitely waiting on
server restart.


My code is:
----------------------------------------------------------------------------------------
boost::shared_ptr<TSocket> socket = boost::shared_ptr<TSocket>(
        new TSocket(server_host_, server_port_));
    socket->setConnTimeout(ThriftConf::connection_timeout_);
    socket->setRecvTimeout(ThriftConf::recv_timeout_);
    socket->setSendTimeout(ThriftConf::send_timeout_);
    boost::shared_ptr<TTransport> tr =
boost::shared_ptr<TBufferedTransport>(
        new TBufferedTransport(socket));
    boost::shared_ptr<TBinaryProtocol> p =
boost::shared_ptr<TBinaryProtocol>(
        new TBinaryProtocol(tr));

----------------------------------------------------------------------------------------------------

Where values are:
(gdb) print ThriftConf::connection_timeout_
$1 = 360000
(gdb) print ThriftConf::recv_timeout_
$2 = 3600000
(gdb) print ThriftConf::send_timeout_
$3 = 180000


regards
Vivek Goel