Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 08531200D08 for ; Thu, 21 Sep 2017 16:10:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 070561609E4; Thu, 21 Sep 2017 14:10:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4D5791609B8 for ; Thu, 21 Sep 2017 16:10:05 +0200 (CEST) Received: (qmail 8835 invoked by uid 500); 21 Sep 2017 14:10:04 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 8824 invoked by uid 99); 21 Sep 2017 14:10:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Sep 2017 14:10:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C9B9EC03F4 for ; Thu, 21 Sep 2017 14:10:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id VEFTufsz2WNc for ; Thu, 21 Sep 2017 14:10:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id E459561032 for ; Thu, 21 Sep 2017 14:10:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 28FBAE0EF1 for ; Thu, 21 Sep 2017 14:10:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 8CEF524185 for ; Thu, 21 Sep 2017 14:10:00 +0000 (UTC) Date: Thu, 21 Sep 2017 14:10:00 +0000 (UTC) From: "James E. King, III (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (THRIFT-4312) Erlang client cannot connect to Python server: exception error: econnrefused MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 21 Sep 2017 14:10:06 -0000 [ https://issues.apache.org/jira/browse/THRIFT-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] James E. King, III resolved THRIFT-4312. ---------------------------------------- Resolution: Fixed Fix Version/s: 0.11.0 > Erlang client cannot connect to Python server: exception error: econnrefused > ---------------------------------------------------------------------------- > > Key: THRIFT-4312 > URL: https://issues.apache.org/jira/browse/THRIFT-4312 > Project: Thrift > Issue Type: Bug > Components: Erlang - Library, Python - Library, Tutorial > Affects Versions: 0.10.0 > Environment: Windows 10 > Erlang OTP 20 > Python 3.6.2 > Reporter: Walter Weinmann > Assignee: James E. King, III > Labels: Connection, Erlang, Python, Tutorial > Fix For: 0.11.0 > > > h3. Connecting the Erlang client with the Python server gives connection error: > h3. > h4. Erlang client: > h4. > h4. > -- the examples are taken from the Apache Thrift tutorials --- > {quote}-module(client). > -include("calculator_thrift.hrl"). > -export([t/0]). > p(X) -> > io:format("~p~n", [X]), > ok. > t() -> > Port = 9090, > {ok, Client0} = thrift_client_util:new("localhost", > Port, > calculator_thrift, > []), > {Client1, {ok, ok}} = thrift_client:call(Client0, ping, []), > io:format("ping~n", []), > {Client2, {ok, Sum}} = thrift_client:call(Client1, add, [1, 1]), > io:format("1+1=~p~n", [Sum]), > {Client3, {ok, Sum1}} = thrift_client:call(Client2, add, [1, 4]), > io:format("1+4=~p~n", [Sum1]), > Work = #'Work'{op=?TUTORIAL_OPERATION_SUBTRACT, > num1=15, > num2=10}, > {Client4, {ok, Diff}} = thrift_client:call(Client3, calculate, [1, Work]), > io:format("15-10=~p~n", [Diff]), > {Client5, {ok, Log}} = thrift_client:call(Client4, getStruct, [1]), > io:format("Log: ~p~n", [Log]), > Client6 = > try > Work1 = #'Work'{op=?TUTORIAL_OPERATION_DIVIDE, > num1=1, > num2=0}, > {ClientS1, {ok, _Quot}} = thrift_client:call(Client5, calculate, [2, Work1]), > io:format("LAME: exception handling is broken~n", []), > ClientS1 > catch > throw:{ClientS2, Z} -> > io:format("Got exception where expecting - the " ++ > "following is NOT a problem!!!~n"), > p(Z), > ClientS2 > end, > {Client7, {ok, ok}} = thrift_client:call(Client6, zip, []), > io:format("zip~n", []), > {_Client8, ok} = thrift_client:close(Client7), > ok. > {quote} > h4. Python server: > h4. > {quote}#!/usr/bin/env python > from tutorial import Calculator > from tutorial.ttypes import InvalidOperation, Operation > from shared.ttypes import SharedStruct > from thrift.transport import TSocket > from thrift.transport import TTransport > from thrift.protocol import TBinaryProtocol > from thrift.server import TServer > class CalculatorHandler: > def __init__(self): > self.log = {} > def ping(self): > print('ping()') > def add(self, n1, n2): > print('add(%d,%d)' % (n1, n2)) > return n1 + n2 > def calculate(self, logid, work): > print('calculate(%d, %r)' % (logid, work)) > if work.op == Operation.ADD: > val = work.num1 + work.num2 > elif work.op == Operation.SUBTRACT: > val = work.num1 - work.num2 > elif work.op == Operation.MULTIPLY: > val = work.num1 * work.num2 > elif work.op == Operation.DIVIDE: > if work.num2 == 0: > x = InvalidOperation() > x.whatOp = work.op > x.why = 'Cannot divide by 0' > raise x > val = work.num1 / work.num2 > else: > x = InvalidOperation() > x.whatOp = work.op > x.why = 'Invalid operation' > raise x > log = SharedStruct() > log.key = logid > log.value = '%d' % (val) > self.log[logid] = log > return val > def getStruct(self, key): > print('getStruct(%d)' % (key)) > return self.log[key] > def zip(self): > print('zip()') > if __name__ == '__main__': > handler = CalculatorHandler() > processor = Calculator.Processor(handler) > transport = TSocket.TServerSocket(port=9090) > tfactory = TTransport.TBufferedTransportFactory() > pfactory = TBinaryProtocol.TBinaryProtocolFactory() > server = TServer.TSimpleServer(processor, transport, tfactory, pfactory) > # You could do one of these for a multithreaded server > # server = TServer.TThreadedServer( > # processor, transport, tfactory, pfactory) > # server = TServer.TThreadPoolServer( > # processor, transport, tfactory, pfactory) > print('Starting the server...') > server.serve() > print('done.') > {quote} > h4. Runtime protocol: > h4. > {quote}EBIN Path : D:\SoftDevelopment\Projects\erlang-and-thrift_idea\erlang-and-thrift\_build\default\lib\erlang_and_thrift\ebin D:\SoftDevelopment\Projects\erlang-and-thrift_idea\erlang-and-thrift\_build\default\lib\jsx\ebin D:\SoftDevelopment\Projects\erlang-and-thrift_idea\erlang-and-thrift\_build\default\lib\thrift\ebin > ------------------------------------------ > Eshell V9.0 (abort with ^G) > 1> client:t(). > ** exception error: no match of right hand side value {error,econnrefused} > in function client:t/0 (d:/SoftDevelopment/Projects/erlang-and-thrift_idea/erlang-and-thrift/_build/default/lib/erlang_and_thrift/src/client.erl, line 33) > 2> Terminate batch job (Y/N)? y > D:\SoftDevelopment\Projects\erlang-and-thrift_idea\erlang-and-thrift>tcping64 localhost 9090 > Probing ::1:9090/tcp - Port is open - time=0.580ms > Probing ::1:9090/tcp - Port is open - time=0.622ms > Probing ::1:9090/tcp - Port is open - time=1.038ms > Probing ::1:9090/tcp - Port is open - time=1.050ms > Ping statistics for ::1:9090 > 4 probes sent. > 4 successful, 0 failed. > Approximate trip times in milli-seconds: > Minimum = 0.580ms, Maximum = 1.050ms, Average = 0.822ms{quote} -- This message was sent by Atlassian JIRA (v6.4.14#64029)