pinterest / riffed

Provides idiomatic Elixir bindings for Apache Thrift
Apache License 2.0
308 stars 37 forks source link

Writing an elixir thrift client. How do you choose the protocol? #14

Closed fire closed 8 years ago

fire commented 8 years ago

Trying to connect to an existing server in java. How do you select the protocol? The server appears to be using the cp protocol, but in the future the client library can be ssl too.

fire commented 8 years ago

I was able to connect using the Binary Protocol and no framing. However I wish to support ssl.

scohen commented 8 years ago

When you call ClientModule.connect(host, port), that should pass the client_options that you defined into thrift_client_util.new.

from https://github.com/apache/thrift/blob/master/lib/erl/src/thrift_client_util.erl#L46, you should be able to add ssltransport: true to your client_opts, which should enable ssl. You do the same thing (framed: true) to enable framing.

fire commented 8 years ago

Actually, do you know when the compact protocol will be supported? It seems to require a pre-release.

scohen commented 8 years ago

Looks like master has an option for compact, but it's not in 0.9.3. My guess is that it'll be in the next release (I don't know when that will be), which will affect riffed as well, and make it much easier to build clients and servers.

With the exception of compact, did this work for you?

scohen commented 8 years ago

Oh, would you like me to update the docs to show how to choose protocols?

fire commented 8 years ago

I was able to test binary protocol and framing disabled, but not sure about ssl.

Do you know if the server is compatible with letsencrypt? Also, does elixir use the default linux / windows certificate authority list?

scohen commented 8 years ago

We use framed binary, and interoperate with a bunch of other languages, so I'm positive they work. Our configs look like this:

  client_opts: [
    framed: true,
    retries: 3
  ]

That'll give you binary + framed.

We don't use letsencrypt, so I don't know about that. You can add keys to the erlang application, which you might need to do to get it working. Details here: http://erlang.org/doc/man/ssl.html

You can also ask on the elixir-lang IRC channel on Freenode. They're extremely helpful with this kind of thing.

scohen commented 8 years ago

@fire, does that help?

fire commented 8 years ago

Yes, but I need more work on the ssl.

scohen commented 8 years ago

Closing, as this is more of a thrift implementation issue (and we talked in IRC)