Release Notes

0.25.0

The exceptions_include_traces application variable now defaults to false. When a handler crashes, the TApplicationException sent back to the caller no longer carries the crash term and the Erlang stack trace; the crash is still logged locally in full through error_logger. Set it back if you want the old behaviour:

application:set_env(thrift, exceptions_include_traces, true).

or, in sys.config:

{thrift, [{exceptions_include_traces, true}]}

thrift_json_protocol now reads the messages it writes, and a read ends where its message does, so the protocol also works over socket and framed transports. Strings are written as quoted and escaped JSON strings, also when given as binaries. Booleans are still written as true and false, and binary fields as plain strings, where the other bindings’ JSON protocols use 1/0 and base64.

thrift_http_transport no longer reads a reply of any length. It gives up on one longer than 100 MB, the default maximum message size of the other Thrift bindings, as soon as it is past that, and the flush that sent the request returns {error, {message_size_exceeds_maximum, Max}}. Set another limit for all HTTP transports with

application:set_env(thrift, max_message_size, Bytes).

or, in sys.config, {thrift, [{max_message_size, Bytes}]}, and for a single one with the {max_message_size, Bytes} option of thrift_http_transport:new/3.

httpc hands a 200 (or 206) reply over as it arrives, but reads any other reply whole before the transport sees it. Such a reply is held to the limit only where httpc takes the max_body_size request option (OTP 27.3.4.17, 28.5.0.6, 29.0.6 and later), and only when it declares its length or is chunked.

thrift_http_transport:new/3 takes a {scheme, https} option; http stays the default. For https, the transport has the server’s certificate and host name checked against the system’s trusted roots, as httpc:ssl_verify_host_options(true) would, also on OTP 25, where httpc checks nothing unless asked to. TLS options of your own go into {http_options, [{ssl, TlsOptions}]} and take the place of the matching defaults. Naming roots with cacerts or cacertfile replaces the system’s roots:

thrift_http_transport:new(Host, Path, [
    {scheme, https},
    {http_options, [{ssl, [{cacertfile, "/path/to/ca.pem"}]}]}
]).

0.9.2

as of 0.9.2 struct and function naming conventions have changed. to retain the old naming conventions (for backwards compatibility) use the compiler option legacynames

Example

Example session using thrift_client:

1> {ok, C0} = thrift_client_util:new("localhost", 9090, thrift_test_thrift, []), ok.
ok
2> {C1, R1} = thrift_client:call(C0, testVoid, []), R1.
{ok,ok}
3> {C2, R2} = thrift_client:call(C1, testVoid, [asdf]), R2.
{error,{bad_args,testVoid,[asdf]}}
4> {C3, R3} = thrift_client:call(C2, testI32, [123]), R3.
{ok,123}
5> {C4, R4} = thrift_client:call(C3, testOneway, [1]), R4.
{ok,ok}
6> {C5, R5} = thrift_client:call(C4, testXception, ["foo"]), R5.
{error,{no_function,testXception}}
7> {C6, R6} = thrift_client:call(C5, testException, ["foo"]), R6.
{ok,ok}
8> {C7, R7} = (catch thrift_client:call(C6, testException, ["Xception"])), R7.
{exception,{xception,1001,<<"Xception">>}}