You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Andrew Cox <an...@gmail.com> on 2012/08/11 20:47:11 UTC
Re: onComplete() callback isn't executed using AsyncClient
Yes. But the only nonblocking transport implemented is the raw
TNonblockingSocket and your Python server seems to want a framed transport.
So your java client is sending messages without framing (without a message
size before the message) while the python server requires messages with
framing.
You can either change your python server *not* to use framed, or you'll
need to build a framed non-blocking transport.
On Wed, Aug 8, 2012 at 7:01 PM, Drulea, Sherban <
Sherban.Drulea@activision.com> wrote:
> Hey Guys,
>
> On further inspection, the threads executes onError() with the following
> error message:
>
> "java.io.IOException: Read call frame size failed"
>
> My thrift server is Python and my thrift asyncclient is Java initialized
> with TBinaryProtocol.Factory(), TAsyncClientManager(), and
> TNonblockingSocket().
>
> Can Python Thrift servers handle async client calls?
>
> Cheers,
> Sherban
>
> From: <Drulea>, Sherban Drulea <sherban.drulea@activision.com<mailto:
> sherban.drulea@activision.com>>
> Date: Wednesday, August 8, 2012 6:43 PM
> To: "user@thrift.apache.org<ma...@thrift.apache.org>" <
> user@thrift.apache.org<ma...@thrift.apache.org>>
> Cc: Pierre Schiro <Pierre@codeparticle.com<mailto:Pierre@codeparticle.com
> >>
> Subject: onComplete() callback isn't executed using AsyncClient
>
> Hey Guys,
>
> I wrote an AsyncClient and callback class. The callback's onComplete()
> function, however, is never executed. The execution stack ends after waking
> up the thread that should execute the callback.
>
> public class UserStatsRepository implements IUserStatsRepository,
> InitializingBean {
> …
> / * THIS IS MY CALLBACK IMPLEMENTATION */
> private class _PlayerStatsCallback implements
> AsyncMethodCallback<getPlayerStats_call>{
> UserStatsRepository userRepo;
>
> _PlayerStatsCallback( UserStatsRepository userRepo )
> {
> this.userRepo = userRepo;
> }
>
> @Override
> public void onComplete(getPlayerStats_call response) {
> try {
> _LOG.error("Calling onComplete with results " +
> response.getResult().toString() );
> this.userRepo._playerStats = response.getResult();
> } catch (ServiceException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (TException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
>
> @Override
> public void onError(Exception exception) {
> // TODO Auto-generated method stub
> exception.printStackTrace();
> };
> }
> …
> public UserStatsModel getUserStats(String userCompactDwid) throws
> BeachheadException {
> …
> / * This instantiates an ASyncClient with
> TBinaryProtocol.Factory(), TAsyncClientManager(), and TNonblockingSocket()
> */
> PlayerStatsAPI.AsyncClient client = _asynchPool.borrow();
> _PlayerStatsCallback callback = new _PlayerStatsCallback(this);
>
> try {
> …
> PlayerStatsParams params = new PlayerStatsParams();
> …
>
> client.getPlayerStats(params, callback);
>
> } catch (Exception e) {
> _LOG.error("Exception thrown while attempting to retrieve user
> stats: ", e);
>
> } finally {
> _asynchPool.release(client);
> }
> return
> getUserStatsInternal(callback.userRepo._playerStats.getStats(), dwidm);
> }
>
> 1. Start with client.getPlayerStats(params, callback);
> 2. Goes to auto-generated getPlayerStatsCode() function AsyncCLient
> code :
>
> public void getPlayerStats(PlayerStatsParams params,
> org.apache.thrift.async.AsyncMethodCallback<getPlayerStats_call>
> resultHandler) throws org.apache.thrift.TException {
> checkReady(); getPlayerStats_call method_call = new
> getPlayerStats_call(params, resultHandler, this, ___protocolFactory,
> ___transport); this.___currentMethod = method_call;
> ___manager.call(method_call); }
> 3. Makes it ___manager.call(method_call);
> 4. Goes to TAsyncClientManage.call()
> 5. Makes it to selectThread.getSelector().wakeup();
> 6. Exits! _PlayerStatsCallback.onComplete() is never called!
>
> Any ideas why onComplete() isn't executed?
>
> Cheers,
> Sherban
>
> 1.
>
> Cheers,
> Sherban
>
Re: onComplete() callback isn't executed using AsyncClient
Posted by David Nadlinger <co...@klickverbot.at>.
On Sat, Aug 11, 2012 at 8:47 PM, Andrew Cox <an...@gmail.com> wrote:
> You can either change your python server *not* to use framed, or you'll
> need to build a framed non-blocking transport.
I think you got this precisely the wrong way round: As far as I know
(the Java implementation is not exactly my domain of expertise)
TAsyncClient *requires* a framed transport to be used, as it relies on
the message boundaries being known at the transport level.
Sherban, have you specified a TFramedTransportFactory as the
transportFactory for your Python server? If not, this should probably
do the trick.
David