You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Phillip B Oldham <ph...@gmail.com> on 2009/03/24 13:51:58 UTC

TSocket: timed out reading 4 bytes from...

I have a Java Thrift server which is being accessed by both a PHP and
Python client. The server has one method, which takes a couple of
seconds to fire-up and respond the first time (due to library loading,
etc). The python client doesn't have any issues with this, but the PHP
client always throws an error the first time it's called:

TSocket: timed out reading 4 bytes from {server}:{port}

Any ideas why this might be happening and how to fix?

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Phillip B Oldham <ph...@gmail.com>.
On Tue, Mar 24, 2009 at 4:31 PM, Bryan Duxbury <br...@rapleaf.com> wrote:
> Maybe we should change setRecvTimeout to setRecvTimeoutMs to make that
> clearer?

Good idea; less ambiguous.

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Bryan Duxbury <br...@rapleaf.com>.
Maybe we should change setRecvTimeout to setRecvTimeoutMs to make  
that clearer?

-Bryan

On Mar 24, 2009, at 9:00 AM, Phillip B Oldham wrote:

> Further testing and reading of the source has provided a fix:
>
> $timeout = 10; // in seconds.
> $socket = new TSocket($settings['host'], $settings['port']);
> $socket->setRecvTimeout($timeout*1000);
>
> Thanks for your help guys!
>
> -- 
> Phillip B Oldham
> phillip.oldham@gmail.com
> +44 (0) 7525 01 09 01


Re: TSocket: timed out reading 4 bytes from...

Posted by Phillip B Oldham <ph...@gmail.com>.
Further testing and reading of the source has provided a fix:

$timeout = 10; // in seconds.
$socket = new TSocket($settings['host'], $settings['port']);
$socket->setRecvTimeout($timeout*1000);

Thanks for your help guys!

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Phillip B Oldham <ph...@gmail.com>.
On Tue, Mar 24, 2009 at 3:36 PM, Phillip B Oldham
<ph...@gmail.com> wrote:
> On Tue, Mar 24, 2009 at 3:10 PM, Krzysztof Godlewski
> <kr...@dajerade.pl> wrote:
>> It looks like you are either using TBufferedTransport client-side and
>> TFramedTransport server-side
>
> Using TBufferedTransport clientside (php):
> $resource = new TBufferedTransport($socket, 1024, 1024);

FYI, using...

$resource = new TFramedTransport($socket);

...fails in PHP for every request.

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Phillip B Oldham <ph...@gmail.com>.
On Tue, Mar 24, 2009 at 3:10 PM, Krzysztof Godlewski
<kr...@dajerade.pl> wrote:
> It looks like you are either using TBufferedTransport client-side and
> TFramedTransport server-side

Using TBufferedTransport clientside (php):
$resource = new TBufferedTransport($socket, 1024, 1024);

Not sure what's being used on the server-side (java):
TServerTransport serverTransport = new TServerSocket(9000);
TServer server = new TSimpleServer(processor, serverTransport);

Does java default to TFramed rather than TBuffered?

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Krzysztof Godlewski <kr...@dajerade.pl>.
It looks like you are either using TBufferedTransport client-side and  
TFramedTransport server-side, or have a very short timeout set in the  
client.


W dniu 2009-03-24, o godz. 13:51, Phillip B Oldham <phillip.oldham@gmail.com 
 > napisaƂ(a):

> I have a Java Thrift server which is being accessed by both a PHP and
> Python client. The server has one method, which takes a couple of
> seconds to fire-up and respond the first time (due to library loading,
> etc). The python client doesn't have any issues with this, but the PHP
> client always throws an error the first time it's called:
>
> TSocket: timed out reading 4 bytes from {server}:{port}
>
> Any ideas why this might be happening and how to fix?
>
> -- 
> Phillip B Oldham
> phillip.oldham@gmail.com
> +44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Phillip B Oldham <ph...@gmail.com>.
On Tue, Mar 24, 2009 at 2:57 PM, Bryan Duxbury <br...@rapleaf.com> wrote:
> Does the PHP client have a socket timeout configured that is less than the
> wait time? That'd be my first thing to check.

Not sure... tried setting the following:

$socket->setSendTimeout(30);
$socket->setRecvTimeout(30);

but the problem persists.

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Re: TSocket: timed out reading 4 bytes from...

Posted by Bryan Duxbury <br...@rapleaf.com>.
Does the PHP client have a socket timeout configured that is less  
than the wait time? That'd be my first thing to check.

-Bryan

On Mar 24, 2009, at 5:51 AM, Phillip B Oldham wrote:

> I have a Java Thrift server which is being accessed by both a PHP and
> Python client. The server has one method, which takes a couple of
> seconds to fire-up and respond the first time (due to library loading,
> etc). The python client doesn't have any issues with this, but the PHP
> client always throws an error the first time it's called:
>
> TSocket: timed out reading 4 bytes from {server}:{port}
>
> Any ideas why this might be happening and how to fix?
>
> -- 
> Phillip B Oldham
> phillip.oldham@gmail.com
> +44 (0) 7525 01 09 01