Code Monkey home page Code Monkey logo

Comments (6)

emaxerrno avatar emaxerrno commented on September 25, 2024 2

FYI: I fixed the problem of negative size frame by doing this:

    val frameFactory = new ThriftFrameCodecFactory(){
      override def create(maxFrameSize: Int,
        defaultProtocolFactory: TProtocolFactory): ChannelHandler = {
        // TODO(agallego): This is A HACK!
        // https://github.com/facebook/nifty/issues/144

        // import com.google.common.base.Verify.verify
        // verify(maxFrameSize > 0, s"Frame size ($maxFrameSize) is negative!")
        val twogb:Int = 1 << 30
        new DefaultThriftFrameCodec(twogb, defaultProtocolFactory)
      }
    }

from nifty.

emaxerrno avatar emaxerrno commented on September 25, 2024

Forgot to mention that I am also using the Binary protocol & TFramed transport.

from nifty.

emaxerrno avatar emaxerrno commented on September 25, 2024

I also tried the client (python) with thrift 0.9.2 and 0.9.3

from nifty.

emaxerrno avatar emaxerrno commented on September 25, 2024

I've also, preloaded the netty version

  "io.netty" % "netty-all" % "4.0.34.Final",

to my dependencies to make sure this happens with both libs.

my python client code looks like this

def tproto(ip, port):
    socket = TSocket.TSocket(ip, port)
    transport = TTransport.TFramedTransport(socket)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    return (protocol, transport)

def get_sched_service_client(ip, port):
    (protocol, transport) = tproto(ip, port)
    client = MyClass.Client(protocol)
    transport.open()
    return client

from nifty.

stormning avatar stormning commented on September 25, 2024

perhaps we can use this?

ThriftServerDef serverDef = thriftServerDefBuilder.limitFrameSizeTo(Integer.MAX_VALUE).build();

from nifty.

andrewcox avatar andrewcox commented on September 25, 2024

Bug here is that we should limit max frame size to under 2GB. Maybe should even be limited to just under 1GB I think. At exactly 2GB, you have bit 31 set, which Java treats as negative i32, and anyway thrift doesn't want you to set that bit because a server that understands different incoming protocols from different clients uses it to detect unframed messages.

As for 1GB, its for a similar reason, some Thrift servers also want to leave that space (with either of top two bits set) to detect HTTP incoming messages.

So yes it is a bug, but the bug is we should not allow a large size like that. And your workaround is perfect.

from nifty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.