[jira] [Commented] (THRIFT-4465) TNonblockingServer throwing THRIFT LOGGER: TConnection::workSocket(): THRIFT_EAGAIN (unavailable resources)

2018-01-22 Thread JIRA

[ 
https://issues.apache.org/jira/browse/THRIFT-4465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16335314#comment-16335314
 ] 

Buğra Gedik commented on THRIFT-4465:
-

I created the PR that fixes this here: 
https://github.com/apache/thrift/pull/1476

> TNonblockingServer throwing THRIFT LOGGER: TConnection::workSocket(): 
> THRIFT_EAGAIN (unavailable resources)
> ---
>
> Key: THRIFT-4465
> URL: https://issues.apache.org/jira/browse/THRIFT-4465
> Project: Thrift
>  Issue Type: Bug
>  Components: C++ - Library
>Affects Versions: 0.11.0
>Reporter: Buğra Gedik
>Priority: Critical
>
> Once I upgraded to 0.11.0, I'm getting the following error occasionally:
> THRIFT LOGGER: TConnection::workSocket(): THRIFT_EAGAIN (unavailable 
> resources)
> I tracked this to the following change: 
> [https://github.com/apache/thrift/commit/808d143245f4f5c30600fab31cf9db854cbf5b48#diff-fe8fec8ec38ea35df64cfcc305e3ab08]
>   
> {code:java}
> // Work the socket right away
> - // workSocket();
> + workSocket();
> {code}
> While adding SSL support, @dthaluru has re-activated the above line. From my 
> own testing, this causes occasional THRIFT_EAGAIN exceptions. It seems like 
> this is due to calling workSocket() too early and the socket gets a read call 
> in non-blocking mode before it has data.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] thrift issue #1476: Remove premature call to workSocket() in TNonblockingSer...

2018-01-22 Thread bgedik
Github user bgedik commented on the issue:

https://github.com/apache/thrift/pull/1476
  
@jeking3 This is ready for review now.


---


[jira] [Created] (THRIFT-4469) isServing is not thread safe

2018-01-22 Thread Robert Joseph Evans (JIRA)
Robert Joseph Evans created THRIFT-4469:
---

 Summary: isServing is not thread safe
 Key: THRIFT-4469
 URL: https://issues.apache.org/jira/browse/THRIFT-4469
 Project: Thrift
  Issue Type: Bug
  Components: Java - Library
Affects Versions: 0.11.0, 0.10.0, 0.9.3, 0.12.0, 1.0
Reporter: Robert Joseph Evans


We have some integration tests in storm were we create a TServer and call serve 
on it in a background thread, because it is a blocking call.

Then in the main thread we wait for up to 10 seconds for isServing to return 
success with a 100ms sleep in between each call.

I don't know if this is a java bug or what, but in some not so rare cases 
isServing does not return true during the entire 10 seconds and the test fails. 
 The test prints out a stack trace when this happens and the background thread 
running the server is always at

https://github.com/apache/thrift/blob/b636ffb613ab49e0f037fbe696d28a4b17a72c5f/lib/java/src/org/apache/thrift/server/AbstractNonblockingServer.java#L95

happily serving.

So either we got very unlucky many times and it takes just a few ms longer than 
10 seconds to come up some times, and < 1 sec other times, or java is doing 
something strange some of the time, and because Server.isServing is not 
volatile the checking thread caches a copy of it in a register and never 
updates it during the 10 seconds of the test run.

Even if it is a java bug, which I could argue probably is, it would be good to 
make isServing volatile.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (THRIFT-4460) php library use PSR-2

2018-01-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/THRIFT-4460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16334982#comment-16334982
 ] 

ASF GitHub Bot commented on THRIFT-4460:


Github user RobberPhex commented on a diff in the pull request:

https://github.com/apache/thrift/pull/1472#discussion_r163079208
  
--- Diff: build/docker/scripts/sca.sh ---
@@ -49,6 +49,10 @@ flake8 --ignore=E501 test/test.py
 flake8 --ignore=E501,E722 test/crossrunner
 flake8 test/features
 
+# PHP code style
+composer install --quiet
+./vendor/bin/phpcs
--- End diff --

@jeking3 
`phpcs` will check which PHP library match PSR-2.(like `flake8`)


> php library use PSR-2
> -
>
> Key: THRIFT-4460
> URL: https://issues.apache.org/jira/browse/THRIFT-4460
> Project: Thrift
>  Issue Type: Improvement
>  Components: PHP - Library
>Affects Versions: 0.11.0
>Reporter: Robert Lu
>Assignee: Robert Lu
>Priority: Minor
>
> PHP Library can use [PSR-2|http://www.php-fig.org/psr/psr-2/] as code standard



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] thrift pull request #1472: THRIFT-4460: PHP Library use PSR-2

2018-01-22 Thread RobberPhex
Github user RobberPhex commented on a diff in the pull request:

https://github.com/apache/thrift/pull/1472#discussion_r163079208
  
--- Diff: build/docker/scripts/sca.sh ---
@@ -49,6 +49,10 @@ flake8 --ignore=E501 test/test.py
 flake8 --ignore=E501,E722 test/crossrunner
 flake8 test/features
 
+# PHP code style
+composer install --quiet
+./vendor/bin/phpcs
--- End diff --

@jeking3 
`phpcs` will check which PHP library match PSR-2.(like `flake8`)


---


[GitHub] thrift issue #1476: Remove premature call to workSocket() in TNonblockingSer...

2018-01-22 Thread bgedik
Github user bgedik commented on the issue:

https://github.com/apache/thrift/pull/1476
  
@jeking3 My latest fix worked fine, but failed to compile on windows. I'll 
rework to something that works for all platforms.


---


[GitHub] thrift issue #1474: Recognize fbthrift TApplicationException codes

2018-01-22 Thread jeking3
Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1474
  
In general I frown upon adding test-only values in production code (like 
"injected failure").  That said I see no reason for us not to incorporate these 
into the core.  Do we really need to ask for permission to add three additional 
error codes from fbthrift?  This may not have properly gotten every language 
(Common Lisp comes to mind, as it's an open PR).

It's too bad we don't define the list of error codes in Thrift and then 
compile them for every language to use... it would ensure uniformity across 
languages...


---


[jira] [Commented] (THRIFT-82) Common Lisp support

2018-01-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/THRIFT-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16334636#comment-16334636
 ] 

ASF GitHub Bot commented on THRIFT-82:
--

Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1412
  
Currently "make cross" builds on Xenial and it will probably stay that way 
for a while.

It would be acceptable to use a different version, either from an ubuntu 
PPA or just downloading and building it as part of the docker image setup.


> Common Lisp support
> ---
>
> Key: THRIFT-82
> URL: https://issues.apache.org/jira/browse/THRIFT-82
> Project: Thrift
>  Issue Type: New Feature
>Reporter: Patrick Collison
>Assignee: James E. King, III
>Priority: Major
> Fix For: 0.12.0
>
> Attachments: thrift-cl.patch
>
>
> Common Lisp support is attached



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] thrift issue #1412: [THRIFT-82] Add Common Lisp support

2018-01-22 Thread jeking3
Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1412
  
Currently "make cross" builds on Xenial and it will probably stay that way 
for a while.

It would be acceptable to use a different version, either from an ubuntu 
PPA or just downloading and building it as part of the docker image setup.


---


[GitHub] thrift issue #1468: THRIFT-(1418|1507|3983|4120|4178|4259|4294): Multiple is...

2018-01-22 Thread jeking3
Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1468
  
Well, I did let folks know, but nobody appears to be looking is there 
going to be a change to the "making a release" that needs to be documented?


---


[jira] [Commented] (THRIFT-4460) php library use PSR-2

2018-01-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/THRIFT-4460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16334629#comment-16334629
 ] 

ASF GitHub Bot commented on THRIFT-4460:


Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1472
  
Are there any tools we can run as part of the build (like flake8) that 
would validate PSR-2?


> php library use PSR-2
> -
>
> Key: THRIFT-4460
> URL: https://issues.apache.org/jira/browse/THRIFT-4460
> Project: Thrift
>  Issue Type: Improvement
>  Components: PHP - Library
>Affects Versions: 0.11.0
>Reporter: Robert Lu
>Assignee: Robert Lu
>Priority: Minor
>
> PHP Library can use [PSR-2|http://www.php-fig.org/psr/psr-2/] as code standard



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] thrift issue #1472: THRIFT-4460: PHP Library use PSR-2

2018-01-22 Thread jeking3
Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1472
  
Are there any tools we can run as part of the build (like flake8) that 
would validate PSR-2?


---


[jira] [Created] (THRIFT-4468) Make the class TGUIConsole thread-safe

2018-01-22 Thread Anton Shchyrov (JIRA)
Anton Shchyrov created THRIFT-4468:
--

 Summary: Make the class TGUIConsole thread-safe
 Key: THRIFT-4468
 URL: https://issues.apache.org/jira/browse/THRIFT-4468
 Project: Thrift
  Issue Type: Improvement
  Components: Delphi - Library
Affects Versions: 0.11.0
Reporter: Anton Shchyrov


In Delphi all methods that refer to VCL should do it only from main thread. But 
class TGUIConsole despite the name does not contain any synchronization methods.

My suggestion is to rename this class to TStringsConsole, make method 
InternalWrite virtual and make new class TGUIConsole inherits from 
TStringsConsole

{{ TGUIConsole = class( TStringsConsole )}}
{{ protected}}
{{  procedure InternalWrite(const S: string; bWriteLine: Boolean); override;}}
{{ end;}}

{{{ TGUIConsole }}}

{{procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);}}
{{begin}}
{{  if TThread.CurrentThread.ThreadID <> MainThreadID then begin}}
{{    TThread.Synchronize(nil, procedure}}
{{      begin}}
{{        inherited InternalWrite(S, bWriteLine);}}
{{      end}}
{{    );}}
{{  end else}}
{{    inherited InternalWrite(S, bWriteLine);}}
{{end;}}

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (THRIFT-4467) Add methods WriteFmt/WriteLineFmt to TThriftConsole class

2018-01-22 Thread Anton Shchyrov (JIRA)

 [ 
https://issues.apache.org/jira/browse/THRIFT-4467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anton Shchyrov updated THRIFT-4467:
---
Description: 
For ease of use, add methods

{{procedure TThriftConsole.WriteFmt(const AFmt: string;}}
 const AArgs: array of const);
 {{begin}}
 {{  Write(Format(AFmt, AArgs));}}
 {{end;}}

{{procedure TThriftConsole.WriteLineFmt(const AFmt: string;}}
 const AArgs: array of const);
 {{begin}}
 {{  WriteLine(Format(AFmt, AArgs));}}
 {{end;}}

 

  was:
For ease of use, add methods

{{procedure TThriftConsole.WriteFmt(const AFmt: string;}}
{{ const AArgs: array of const);}}
{{begin}}
{{  Write(Format(AFmt, AArgs));}}
{{end;}}{{procedure TThriftConsole.WriteLineFmt(const AFmt: string;}}
{{ const AArgs: array of const);}}
{{begin}}
{{  WriteLine(Format(AFmt, AArgs));}}
{{end;}}

 


> Add methods WriteFmt/WriteLineFmt to TThriftConsole class
> -
>
> Key: THRIFT-4467
> URL: https://issues.apache.org/jira/browse/THRIFT-4467
> Project: Thrift
>  Issue Type: Improvement
>  Components: Delphi - Library
>Affects Versions: 0.11.0
>Reporter: Anton Shchyrov
>Priority: Minor
>  Labels: Console
>
> For ease of use, add methods
> {{procedure TThriftConsole.WriteFmt(const AFmt: string;}}
>  const AArgs: array of const);
>  {{begin}}
>  {{  Write(Format(AFmt, AArgs));}}
>  {{end;}}
> {{procedure TThriftConsole.WriteLineFmt(const AFmt: string;}}
>  const AArgs: array of const);
>  {{begin}}
>  {{  WriteLine(Format(AFmt, AArgs));}}
>  {{end;}}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (THRIFT-4467) Add methods WriteFmt/WriteLineFmt to TThriftConsole class

2018-01-22 Thread Anton Shchyrov (JIRA)
Anton Shchyrov created THRIFT-4467:
--

 Summary: Add methods WriteFmt/WriteLineFmt to TThriftConsole class
 Key: THRIFT-4467
 URL: https://issues.apache.org/jira/browse/THRIFT-4467
 Project: Thrift
  Issue Type: Improvement
  Components: Delphi - Library
Affects Versions: 0.11.0
Reporter: Anton Shchyrov


For ease of use, add methods

{{procedure TThriftConsole.WriteFmt(const AFmt: string;}}
{{ const AArgs: array of const);}}
{{begin}}
{{  Write(Format(AFmt, AArgs));}}
{{end;}}{{procedure TThriftConsole.WriteLineFmt(const AFmt: string;}}
{{ const AArgs: array of const);}}
{{begin}}
{{  WriteLine(Format(AFmt, AArgs));}}
{{end;}}

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (THRIFT-4314) configure/build does not work properly wrt --with-boost and --with-libevent

2018-01-22 Thread James E. King, III (JIRA)

[ 
https://issues.apache.org/jira/browse/THRIFT-4314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16334277#comment-16334277
 ] 

James E. King, III commented on THRIFT-4314:


Interesting - I haven't had a chance to look at it yet.

> configure/build does not work properly wrt --with-boost and --with-libevent
> ---
>
> Key: THRIFT-4314
> URL: https://issues.apache.org/jira/browse/THRIFT-4314
> Project: Thrift
>  Issue Type: Bug
>Affects Versions: 0.10.0, 0.11.0
>Reporter: Buğra Gedik
>Assignee: James E. King, III
>Priority: Minor
>
> Trying:
> {{./configure --with-libevent="/opt/foo/ub16/libevent-2.1.18-stable" 
> --with-boost="/opt/foo/ub16/boost-1.65.0" --enable-shared=no 
> --enable-tests=no CFLAGS="-fPIC -g -O2" CXXFLAGS="-fPIC -g -O2"}}
> works, but the build (after typing {{make}}) fails midway complaining that a 
> boost header was not found. A similar problem happens with {{libevent}}. One 
> is forced to do:
> {{./configure --with-libevent="/opt/foo/ub16/libevent-2.1.18-stable" 
> --with-boost="/opt/foo/ub16/boost-1.65.0" --enable-shared=no 
> --enable-tests=no CFLAGS="-fPIC -g -O2" CXXFLAGS="-fPIC -g -O2 
> -I/opt/foo/ub16/boost-1.65.0/include 
> -I/opt/foo/ub16/libevent-2.1.18-stable/include"}}
> Also, if you pass {{--enable-tests=yes}}, then you are also forced to pass 
> {{LDFLAGS="-L/opt/foo/ub16/libevent-2.1.18-stable/lib"}}.
> One should not need to pass these additional -I and -Ls given that 
> --with-boost and --with-libevent are supposed to handle these.
> Finally {{make clean}} fails as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] thrift issue #1476: Remove premature call to workSocket() in TNonblockingSer...

2018-01-22 Thread jeking3
Github user jeking3 commented on the issue:

https://github.com/apache/thrift/pull/1476
  
Yes, concurrency_test has sporadic failures - it is a lot better than it 
used to be; seems to be worse on Visual Studio 10.  Perhaps the solution here 
is to handle EAGAIN properly?


---


[jira] [Updated] (THRIFT-4466) TEvhttpServer don't work with javascript

2018-01-22 Thread Richard Boolman (JIRA)

 [ 
https://issues.apache.org/jira/browse/THRIFT-4466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Boolman updated THRIFT-4466:

Description: 
TEvhttpServer don't work with javascript client.

With c++ client or php client 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}
 
{code:java}
thrift -r --gen cpp:cob_style test1.thrift
thrift -r --gen php test1.thrift
thrift -r --gen js test1.thrift{code}
 

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_ = std::auto_ptr( new test1Handler );
}

void add_val(stdcxx::function cob, const int32_t 
a, const int32_t b ) {
int32_t _ret = 0;

_ret = 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(proc, 
pfact));
shared_ptr server(new TEvhttpServer(bufproc, 9090));

/*IF USE TThreadedServer WILL ALL WORK

shared_ptrtest1( new test1Handler() );
shared_ptr  processor( new test1Processor(test1) );
shared_ptr   transportFactory( new 
THttpServerTransportFactory() );
shared_ptrprotocolFactory( new TJSONProtocolFactory() 
);
shared_ptrserverTransport( new TServerSocket( 9090 ) 
);

shared_ptr server( new TThreadedServer( processor, 
serverTransport, transportFactory, protocolFactory ) );
*/

server->serve();

return 0;
}
{code}
 

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}
 

test1_client.php (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 = 'gen-php';
require_once $GEN_DIR.'/test1.php';
require_once $GEN_DIR.'/Types.php';

try {
$socket = new THttpClient( '127.0.0.1', 9090 );
$transport = new TBufferedTransport( $socket, 1024, 1024 );
$protocol = new TJSONProtocol( $transport );
$client = new test1Client( $protocol );

$transport->open();

echo $client->add_val( 5, 10 );

$transport->close();

} catch ( TException $tx ) {
print 'TException: '.$tx->getMessage()."\n";
}
?>
{code}
 

test1_client.html (DON'T WORK)
{code:java}




Test Thrift










(function() {
var transport = new Thrift.TXHRTransport( "http://127.0.0.1:9090"; );
var protocol = new Thrift.TJSONProtocol( transport );
var client = new test1Client( protocol );

var outputElement = document.getElementById("output");
document.getElementById("get_msg").addEventListener("click", function(){

outputElement.innerHTML = client.add_val( 5, 10 );
});
})();



{code}
 
 *Help please.*

 

  was:
TEvhttpServer don't work with javascript client.

With c++ client or php client 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}
 
{code:java}
thrift -r --gen cpp:cob_style test1.thrift
thrift -r --gen php test1.thrift
thrift -r --gen js test1.thrift{code}
 

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 

[jira] [Created] (THRIFT-4466) TEvhttpServer don't work with javascript

2018-01-22 Thread Richard Boolman (JIRA)
Richard Boolman created THRIFT-4466:
---

 Summary: 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


TEvhttpServer don't work with javascript client.

With c++ client or php client 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}
 
{code:java}
thrift -r --gen cpp:cob_style test1.thrift
thrift -r --gen php test1.thrift
thrift -r --gen js test1.thrift{code}
 

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_ = std::auto_ptr( new test1Handler );
}

void add_val(stdcxx::function cob, const int32_t 
a, const int32_t b ) {
int32_t _ret = 0;

_ret = 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(proc, 
pfact));
shared_ptr server(new TEvhttpServer(bufproc, 9090));

/*IF USE TThreadedServer WILL ALL WORK

shared_ptr test1 = shared_ptr( new 
test1Handler() );
shared_ptr processor = shared_ptr( new 
test1Processor(test1) );
shared_ptrtransportFactory = 
shared_ptr( new THttpServerTransportFactory() );
shared_ptrprotocolFactory = shared_ptr( 
new TJSONProtocolFactory() );
shared_ptrserverTransport = shared_ptr( 
new TServerSocket( 9090 ) );

shared_ptr server = shared_ptr( new 
TThreadedServer( processor,
serverTransport, transportFactory, protocolFactory ) );
*/
server->serve();

return 0;
}
{code}
 

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}
 

test1_client.php (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 = 'gen-php';
require_once $GEN_DIR.'/test1.php';
require_once $GEN_DIR.'/Types.php';

try {
$socket = new THttpClient( '127.0.0.1', 9090 );
$transport = new TBufferedTransport( $socket, 1024, 1024 );
$protocol = new TJSONProtocol( $transport );
$client = new test1Client( $protocol );

$transport->open();

echo $client->add_val( 5, 10 );

$transport->close();

} catch ( TException $tx ) {
print 'TException: '.$tx->getMessage()."\n";
}
?>
{code}
 

test1_client.html (DON'T WORK)
{code:java}




Test Thrift










(function() {
var transport = new Thrift.TXHRTransport( "http://127.0.0.1:9090"; );
var protocol = new Thrift.TJSONProtocol( transport );
var client = new test1Client( protocol );

var outputElement = document.getElementById("output");
document.getElementById("get_msg").addEventListener("click", function(){

outputElement.innerHTML = client.add_val( 5, 10 );
});
})();



{code}
 
 *Help please.*

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)