Note that there are some explanatory texts on larger screens.

plurals
  1. POThrift: Python Server, Erlang Client Errors... {thrift_socket_server,244,{child_error,function_clause,[]}}
    primarykey
    data
    text
    <p>This is actually my first question on stackoverflow, but I've been having a problem that I can't really seem to solve. I'm making a Python server that calls an erlang client through thrift. The only function I've made in thrift is one called bar, which takes in an integer and prints bar (integer). Heres the Python Client, its not too complicated:</p> <pre><code>#!/usr/bin/env python import sys sys.path.append('../gen-py') from foo import Foo from foo.ttypes import * from foo.constants import * from thrift import Thrift from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol try: # Make socket transport = TSocket.TSocket('localhost', 9999) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = Foo.Client(protocol) # Connect! transport.open() msg = client.bar(1452) print msg transport.close() except Thrift.TException, tx: print "%s" % (tx.message) </code></pre> <p>Here is my thrift client, which is listening on port 9999:</p> <pre><code>-module(foo_service). -include("foo_thrift.hrl"). -include("foo_types.hrl"). -export([start_link/0, stop/1, handle_function/2, % Thrift implementations % FILL IN HERE bar/1]). %%%%% EXTERNAL INTERFACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% start_link() -&gt; thrift_socket_server:start ([{port, get_port()}, {name, ?MODULE}, {service, foo_thrift}, {handler, ?MODULE}, {framed, true}, {socket_opts, [{recv_timeout, 60*60*1000}]}]). stop(_Server) -&gt; thrift_socket_server:stop (?MODULE), ok. %%%%% THRIFT INTERFACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% handle_function(Function, Args) when is_atom(Function), is_tuple(Args) -&gt; case apply(?MODULE, Function, tuple_to_list(Args)) of ok -&gt; ok; Reply -&gt; {reply, Reply} end. %%%%% HELPER FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% get_port() -&gt; {ok, Result} = application:get_env(foo, service_port), Result. %% ADD THRIFT FUNCTIONS HERE bar(I) -&gt; io:format("bar (~p)~n", [I]). </code></pre> <p>So I start up the thrift client, and from the python server I call client.bar(1452), and unfortunately get a child error:</p> <pre><code>=CRASH REPORT==== 5-Jul-2013::08:34:32 === crasher: initial call: thrift_socket_server:acceptor_loop/1 pid: &lt;0.51.0&gt; registered_name: [] exception error: no function clause matching thrift_socket_transport:read({data,#Port&lt;0.1067&gt;,3600000}, -2147418111) (src/thrift_socket_transport.erl, line 53) in function thrift_transport:read/2 (src/thrift_transport.erl, line 67) in call from thrift_framed_transport:read/2 (src/thrift_framed_transport.erl, line 79) in call from thrift_transport:read/2 (src/thrift_transport.erl, line 67) in call from thrift_binary_protocol:read_data/2 (src/thrift_binary_protocol.erl, line 315) in call from thrift_binary_protocol:read/2 (src/thrift_binary_protocol.erl, line 286) in call from thrift_binary_protocol:read/2 (src/thrift_binary_protocol.erl, line 175) in call from thrift_protocol:read_specific/2 (src/thrift_protocol.erl, line 186) ancestors: [foo_service,foo_sup,&lt;0.46.0&gt;] messages: [] links: [&lt;0.48.0&gt;,#Port&lt;0.1067&gt;] dictionary: [] trap_exit: false status: running heap_size: 987 stack_size: 27 reductions: 513 neighbours: =ERROR REPORT==== 5-Jul-2013::08:34:32 === {thrift_socket_server,244,{child_error,function_clause,[]}} </code></pre> <p>Any Ideas? Thanks for any help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload