From dev-return-51066-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Mon Jan 22 13:45:08 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 77D04180609 for ; Mon, 22 Jan 2018 13:45:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 67D04160C3A; Mon, 22 Jan 2018 12:45:08 +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 88173160C4B for ; Mon, 22 Jan 2018 13:45:06 +0100 (CET) Received: (qmail 49630 invoked by uid 500); 22 Jan 2018 12:45:05 -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 49616 invoked by uid 99); 22 Jan 2018 12:45:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jan 2018 12:45:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 7CF461A0AFF for ; Mon, 22 Jan 2018 12:45:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -98.71 X-Spam-Level: X-Spam-Status: No, score=-98.71 tagged_above=-999 required=6.31 tests=[KAM_BADIPHTTP=2, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100, WEIRD_PORT=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id cAfCrInNMI8M for ; Mon, 22 Jan 2018 12:45:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 192995F473 for ; Mon, 22 Jan 2018 12:45: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 88825E05FD for ; Mon, 22 Jan 2018 12:45:00 +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 3A7F721206 for ; Mon, 22 Jan 2018 12:45:00 +0000 (UTC) Date: Mon, 22 Jan 2018 12:45:00 +0000 (UTC) From: "Richard Boolman (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (THRIFT-4466) TEvhttpServer don't work with javascript MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4466?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard Boolman updated THRIFT-4466: ------------------------------------ Description:=20 TEvhttpServer don't work with javascript client. With c++ client or php=C2=A0client or other client, will work. Example: test1.thrift {code:java} namespace cpp test1 service test1 { i32 add_val( 1 : i32 a, 2 : i32 b ); } {code} =C2=A0 {code:java} thrift -r --gen cpp:cob_style test1.thrift thrift -r --gen php test1.thrift thrift -r --gen js test1.thrift{code} =C2=A0 evhtp_thrift_server.cpp: {code:java} #include "../gen-cpp/test1.h" #include #include #include #include #include #include #include using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; using namespace ::apache::thrift::async; using boost::shared_ptr; using namespace ::test1; class test1Handler : virtual public test1If { public: int32_t add_val(const int32_t a, const int32_t b) { return a + b; } }; class test1AsyncHandler : public test1CobSvIf { public: test1AsyncHandler() { syncHandler_ =3D std::auto_ptr( new test1Handler ); } void add_val(stdcxx::function cob, const int= 32_t a, const int32_t b ) { int32_t _ret =3D 0; _ret =3D syncHandler_->add_val(a, b); return cob(_ret); } protected: std::auto_ptr syncHandler_; }; int main(int argc, char ** argv) { shared_ptr handler(new test1AsyncHandler()); shared_ptr proc(new test1AsyncProcessor(handler)= ); shared_ptr pfact(new TJSONProtocolFactory()); shared_ptr bufproc(new TAsyncProtocolProcessor(p= roc, pfact)); shared_ptr server(new TEvhttpServer(bufproc, 909= 0)); /* IF USE TThreadedServer WILL ALL WORK shared_ptr test1( new test1Handler() ); shared_ptr processor( new test1Processor(test1) ); shared_ptr transportFactory( new THttpServerTransp= ortFactory() ); shared_ptr protocolFactory( new TJSONProtocolFacto= ry() ); shared_ptr serverTransport( new TServerSocket( 909= 0 ) ); shared_ptr server( new TThreadedServer( processor,= serverTransport, transportFactory, protocolFactory ) ); */ server->serve(); return 0; } {code} =C2=A0 test1_client.cpp: (WORK) {code:java} #include <../gen-cpp/test1.h> #include #include #include #include #include using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; int main(int argc, char ** argv) { boost::shared_ptr transport(new THttpClient("127.0.0.1", 90= 90, "/")); boost::shared_ptr protocol(new TJSONProtocol(transport)); test1::test1Client client(protocol); transport->open(); std::cout << client.add_val( 5, 10 ) << std::endl; transport->close(); return 0; } {code} =C2=A0 test1_client.php=C2=A0(WORK) {code:java} registerNamespace( 'Thrift', $GLOBALS['THRIFT_ROOT'] ); $loader->register(); use Thrift\Protocol\TJSONProtocol; use Thrift\Transport\TSocket; use Thrift\Transport\THttpClient; use Thrift\Transport\TBufferedTransport; use Thrift\Transport\TFramedTransport; use Thrift\Exception\TException; $GEN_DIR =3D 'gen-php'; require_once $GEN_DIR.'/test1.php'; require_once $GEN_DIR.'/Types.php'; try { $socket =3D new THttpClient( '127.0.0.1', 9090 ); $transport =3D new TBufferedTransport( $socket, 1024, 1024 ); $protocol =3D new TJSONProtocol( $transport ); $client =3D new test1Client( $protocol ); $transport->open(); echo $client->add_val( 5, 10 ); $transport->close(); } catch ( TException $tx ) { print 'TException: '.$tx->getMessage()."\n"; } ?> {code} =C2=A0 test1_client.html=C2=A0(DON'T WORK) {code:java} Test Thrift
{code} =C2=A0 *Help please.* =C2=A0 was: TEvhttpServer don't work with javascript client. With c++ client or php=C2=A0client or other client, will work. Example: test1.thrift {code:java} namespace cpp test1 service test1 { i32 add_val( 1 : i32 a, 2 : i32 b ); } {code} =C2=A0 {code:java} thrift -r --gen cpp:cob_style test1.thrift thrift -r --gen php test1.thrift thrift -r --gen js test1.thrift{code} =C2=A0 evhtp_thrift_server.cpp: {code:java} #include "../gen-cpp/test1.h" #include #include #include #include #include #include #include using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; using namespace ::apache::thrift::async; using boost::shared_ptr; using namespace ::test1; class test1Handler : virtual public test1If { public: int32_t add_val(const int32_t a, const int32_t b) { return a + b; } }; class test1AsyncHandler : public test1CobSvIf { public: test1AsyncHandler() { syncHandler_ =3D std::auto_ptr( new test1Handler ); } void add_val(stdcxx::function cob, const int= 32_t a, const int32_t b ) { int32_t _ret =3D 0; _ret =3D syncHandler_->add_val(a, b); return cob(_ret); } protected: std::auto_ptr syncHandler_; }; int main(int argc, char ** argv) { shared_ptr handler(new test1AsyncHandler()); shared_ptr proc(new test1AsyncProcessor(handler)= ); shared_ptr pfact(new TJSONProtocolFactory()); shared_ptr bufproc(new TAsyncProtocolProcessor(p= roc, pfact)); shared_ptr server(new TEvhttpServer(bufproc, 909= 0)); /* IF USE TThreadedServer WILL ALL WORK shared_ptr test1 =3D shared_ptr( new test1H= andler() ); shared_ptr processor =3D shared_ptr( new test1P= rocessor(test1) ); shared_ptrtransportFactory =3D shared_ptr( new THttpServerTransportFactory() ); shared_ptrprotocolFactory =3D shared_ptr( new TJSONProtocolFactory() ); shared_ptrserverTransport =3D shared_ptr( new TServerSocket( 9090 ) ); shared_ptr server =3D shared_ptr( new= TThreadedServer( processor, serverTransport, transportFactory, protocolFactory ) ); */ server->serve(); return 0; } {code} =C2=A0 test1_client.cpp: (WORK) {code:java} #include <../gen-cpp/test1.h> #include #include #include #include #include using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; int main(int argc, char ** argv) { boost::shared_ptr transport(new THttpClient("127.0.0.1", 90= 90, "/")); boost::shared_ptr protocol(new TJSONProtocol(transport)); test1::test1Client client(protocol); transport->open(); std::cout << client.add_val( 5, 10 ) << std::endl; transport->close(); return 0; } {code} =C2=A0 test1_client.php=C2=A0(WORK) {code:java} registerNamespace( 'Thrift', $GLOBALS['THRIFT_ROOT'] ); $loader->register(); use Thrift\Protocol\TJSONProtocol; use Thrift\Transport\TSocket; use Thrift\Transport\THttpClient; use Thrift\Transport\TBufferedTransport; use Thrift\Transport\TFramedTransport; use Thrift\Exception\TException; $GEN_DIR =3D 'gen-php'; require_once $GEN_DIR.'/test1.php'; require_once $GEN_DIR.'/Types.php'; try { $socket =3D new THttpClient( '127.0.0.1', 9090 ); $transport =3D new TBufferedTransport( $socket, 1024, 1024 ); $protocol =3D new TJSONProtocol( $transport ); $client =3D new test1Client( $protocol ); $transport->open(); echo $client->add_val( 5, 10 ); $transport->close(); } catch ( TException $tx ) { print 'TException: '.$tx->getMessage()."\n"; } ?> {code} =C2=A0 test1_client.html=C2=A0(DON'T WORK) {code:java} Test Thrift
{code} =C2=A0 *Help please.* =C2=A0 > TEvhttpServer don't work with javascript > ---------------------------------------- > > Key: THRIFT-4466 > URL: https://issues.apache.org/jira/browse/THRIFT-4466 > Project: Thrift > Issue Type: Bug > Components: C++ - Library, JavaScript - Library > Affects Versions: 0.11.0 > Reporter: Richard Boolman > Priority: Major > Labels: async, javascript, libevent > > TEvhttpServer don't work with javascript client. > With c++ client or php=C2=A0client or other client, will work. > Example: > test1.thrift > {code:java} > namespace cpp test1 > service test1 { > i32 add_val( 1 : i32 a, 2 : i32 b ); > } > {code} > =C2=A0 > {code:java} > thrift -r --gen cpp:cob_style test1.thrift > thrift -r --gen php test1.thrift > thrift -r --gen js test1.thrift{code} > =C2=A0 > evhtp_thrift_server.cpp: > {code:java} > #include "../gen-cpp/test1.h" > #include > #include > #include > #include > #include > #include > #include > using namespace ::apache::thrift; > using namespace ::apache::thrift::protocol; > using namespace ::apache::thrift::transport; > using namespace ::apache::thrift::server; > using namespace ::apache::thrift::async; > using boost::shared_ptr; > using namespace ::test1; > class test1Handler : virtual public test1If { > public: > int32_t add_val(const int32_t a, const int32_t b) { > return a + b; > } > }; > class test1AsyncHandler : public test1CobSvIf { > public: > test1AsyncHandler() { > syncHandler_ =3D std::auto_ptr( new test1Handler ); > } > void add_val(stdcxx::function cob, const i= nt32_t a, const int32_t b ) { > int32_t _ret =3D 0; > _ret =3D syncHandler_->add_val(a, b); > return cob(_ret); > } > protected: > std::auto_ptr syncHandler_; > }; > int main(int argc, char ** argv) { > shared_ptr handler(new test1AsyncHandler()); > shared_ptr proc(new test1AsyncProcessor(handle= r)); > shared_ptr pfact(new TJSONProtocolFactory()); > shared_ptr bufproc(new TAsyncProtocolProcessor= (proc, pfact)); > shared_ptr server(new TEvhttpServer(bufproc, 9= 090)); > /* IF USE TThreadedServer WILL ALL WORK > shared_ptr test1( new test1Handler() ); > shared_ptr processor( new test1Processor(test1) = ); > shared_ptr transportFactory( new THttpServerTran= sportFactory() ); > shared_ptr protocolFactory( new TJSONProtocolFac= tory() ); > shared_ptr serverTransport( new TServerSocket( 9= 090 ) ); > shared_ptr server( new TThreadedServer( processo= r, serverTransport, transportFactory, protocolFactory ) ); > */ > server->serve(); > return 0; > } > {code} > =C2=A0 > test1_client.cpp: (WORK) > {code:java} > #include <../gen-cpp/test1.h> > #include > #include > #include > #include > #include > using namespace apache::thrift; > using namespace apache::thrift::protocol; > using namespace apache::thrift::transport; > int main(int argc, char ** argv) { > boost::shared_ptr transport(new THttpClient("127.0.0.1", = 9090, "/")); > boost::shared_ptr protocol(new TJSONProtocol(transport)); > test1::test1Client client(protocol); > transport->open(); > std::cout << client.add_val( 5, 10 ) << std::endl; > transport->close(); > return 0; > } > {code} > =C2=A0 > test1_client.php=C2=A0(WORK) > {code:java} > error_reporting( E_ALL ); > $GLOBALS['THRIFT_ROOT'] =3D '/usr/lib/php'; > require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/ClassLoader/ThriftClassLoad= er.php'; > use Thrift\ClassLoader\ThriftClassLoader; > $loader =3D new ThriftClassLoader(); > $loader->registerNamespace( 'Thrift', $GLOBALS['THRIFT_ROOT'] ); > $loader->register(); > use Thrift\Protocol\TJSONProtocol; > use Thrift\Transport\TSocket; > use Thrift\Transport\THttpClient; > use Thrift\Transport\TBufferedTransport; > use Thrift\Transport\TFramedTransport; > use Thrift\Exception\TException; > $GEN_DIR =3D 'gen-php'; > require_once $GEN_DIR.'/test1.php'; > require_once $GEN_DIR.'/Types.php'; > try { > $socket =3D new THttpClient( '127.0.0.1', 9090 ); > $transport =3D new TBufferedTransport( $socket, 1024, 1024 ); > $protocol =3D new TJSONProtocol( $transport ); > $client =3D new test1Client( $protocol ); > $transport->open(); > echo $client->add_val( 5, 10 ); > $transport->close(); > } catch ( TException $tx ) { > print 'TException: '.$tx->getMessage()."\n"; > } > ?> > {code} > =C2=A0 > test1_client.html=C2=A0(DON'T WORK) > {code:java} > > > > > Test Thrift > > > >
> > > > > > > {code} > =C2=A0 > *Help please.* > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)