scala - Thrift Debugging: Problems with my finagle server -


i have simple thrift server, implemented in scala finagle:

    import com.twitter.util.{ await, future }     import com.jakiku.thriftscala.{ realtimedatabasepageimpressions, pageimpressions }     import com.twitter.finagle.thrift     import com.twitter.finagle.thrift.thriftserverframedcodec     import com.twitter.finagle.builder.{ serverbuilder, server }      object thriftserver {        def main(args: array[string]) {         val server = thrift.serveiface("localhost:9090", new realtimedatabasepageimpressions[future] {           def getbytrackidandday(trackid: int, day: int) = {             future(seq(pageimpressions.apply(123, 3, 4,  3,  2000l, 2000l)))           }         })         await.ready(server)       }     } 

this thrift file:

    namespace   java com.jakiku.thriftjava     #@namespace scala com.jakiku.thriftscala      typedef i64 long     typedef i32 int      struct pageimpressionssum{         1: required int         trackid;         2: required int         day;         3: required int         hour;         4: required int         minute;         5: required string      pageid;         6: required long        uniqueimpressions;         7: required long        sumimpressions;     }      struct pageimpressions{         1: required int         trackid;         2: required int         day;         3: required int         hour;         4: required int         minute;         6: required long        uniqueimpressions;         7: required long        sumimpressions;     }      service realtimedatabase_pageimpressions{       list<pageimpressions> getbytrackidandday(1:int trackid, 2:int day);     }      service realtimedatabase_pageimpressionssum {       list<pageimpressionssum> getbytrackidandday(1:int trackid, 2:int day);     } 

i generated scala thrift classes scrooge. added thriftlib, scrooge-core, scrooge-generator etc. dependency. added scrooge sbt plugin:

 addsbtplugin("com.twitter" % "scrooge-sbt-plugin" % "4.5.0") 

i started server sudo sbt 'run'. output of console:

[info] running thriftserver mai 25, 2016 4:18:39 com.twitter.finagle.init$$anonfun$1 apply$mcv$sp information: finagle version 6.34.0 (rev=44f444f606b10582c2da8d5770b7879ddd961211) built @ 20160310-155158

everything looks fine, @ moment. tested server in nodejs. doesn't work. used thrift python test suite. every check runs timeout.

this nodejs client:

    var thrift = require('thrift');     var realtime_pageimpressions = require('./gen-nodejs/realtimedatabase_pageimpressions.js');     var ttypes = require('./gen-nodejs/realtimedatabase_types.js');       var connection = thrift.createconnection("localhost", 9090);      connection.on('error', function(err) {         console.log(err);     });      var client = thrift.createclient(realtime_pageimpressions, connection);      client.getbytrackidandday(123124, 4, function(err, response) {         if (err) {         console.error(err);         } else {         console.log(response);         }     }); 

i have no idea i'm doing wrong.

not sure if problem (especially since i'm not familiar scrooge or finagle) looks you're using framed transport on server , maybe not on client.

looking @ node.js thrift library code, seems if tbufferedtransport default, , might want tframedtransport instead.

on node.js thrift tutorial page, show how can initialize connection overridden options:

var thrift = require('thrift'); var thrifttransports = require('thrift/transport'); var thriftprotocols = require('thrift/protocol'); var calculator = require('./gen-nodejs/calculator'); var ttypes = require('./gen-nodejs/tutorial_types');  transport = thrifttransports.tbufferedtransport() protocol = thriftprotocols.tbinaryprotocol()  var connection = thrift.createconnection("localhost", 9090, {   transport : transport,   protocol : protocol }); 

you might try implementing node.js client above, except replace tframedtransport , see if helps.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -