Thrift requires Perl >= 5.10.0
Unexpected exceptions in a service handler are converted to TApplicationException with type INTERNAL ERROR and the string of the exception is delivered as the message.
On the client side, exceptions are thrown with die, so be sure to wrap eval{} statments around any code that contains exceptions.
Please see tutoral and test dirs for examples.
The Perl ForkingServer ignores SIGCHLD allowing the forks to be reaped by the operating system naturally when they exit. This means one cannot use a custom SIGCHLD handler in the consuming perl implementation that calls serve(). It is acceptable to use a custom SIGCHLD handler within a thrift handler implementation as the ForkingServer resets the forked child process to use default signal handling.
The following modules are not provided by Perl 5.10.0 but are required to use Thrift.
This is only required when running tests:
These are only required if using Thrift::HttpClient:
These are only required if using Thrift::SSLSocket or Thrift::SSLServerSocket:
The socket classes were refactored in 0.10.0 so that there is one package per
file. This means use Socket; no longer defines SSLSocket. You can use this
technique to make your application run against 0.10.0 as well as earlier versions:
eval { require Thrift::SSLSocket; } or do { require Thrift::Socket; }
If you need a single version of your code to work with both older and newer thrift namespace changes, you can make the new, correct namespaces behave like the old ones in your files with this technique to create an alias, which will allow you code to run against either version of the perl runtime for thrift:
BEGIN {*TType:: = *Thrift::TType::}
If you need to modify your code to work against both older or newer thrift versions, you can deal with these changes in a backwards compatible way in your projects using eval:
eval { require Thrift::Exception; require Thrift::MessageType; require Thrift::Type; }
or do { require Thrift; }
Thrift::SSLSocket no longer sets SSL_verify_mode on the connections it creates,
so IO::Socket::SSL applies its own defaults instead: it verifies the server’s
certificate chain – against ca when one is given, and against the system trust
store otherwise – and checks the host name it derives from the peer address
against the certificate.
Clients that pass ca are unaffected; that combination already verified both the
chain and the name. Clients that do not pass ca now require the server’s
certificate to be trusted by the system store, and will fail a handshake they
previously completed.
The new verify option, default true, restores the previous handshake for callers
who need it:
my $socket = Thrift::SSLSocket->new(host => $host, port => $port, verify => 0);
A false verify accepts any certificate, which leaves the connection open to
interception, and is only appropriate on a network you already trust.
Thrift::SSLServerSocket is unchanged. The same branch on a listener means “do not
demand a client certificate”, which is the ordinary posture for a TLS server.
Thrift::BinaryProtocol now refuses a string or binary field longer than its maximum
string size before reading it, with a Thrift::TProtocolException of type SIZE_LIMIT.
The maximum defaults to Thrift::BinaryProtocol::DEFAULT_MAX_STRING_SIZE, 16384000
bytes, the frame size limit the framed transports apply. It is the optional second
argument of Thrift::BinaryProtocol->new and the first of
Thrift::BinaryProtocolFactory->new; pass 0 to read strings of any length, as before:
my $protocol = Thrift::BinaryProtocol->new($transport, 0);
Thrift::HttpClient setRecvTimeout() and setSendTimeout() are deprecated. Use setTimeout instead.