This post basically sums the bug with the Ruby Thrift bindings where the exception message is "Incompatible character encodings: ASCII-8BIT and UTF-8". This problem is a bit of a bitch to hunt down but once you find it its relatively easy to fix.
While I've got a fork with a pull request I'm fairly certain that the Apache software foundation has other... means of accepting patches so this pull request will be largely irrelevant.
Until the problem is fixed and propagated to the thrift gem you can monkey patch this issue yourself:
# encoding: utf-8
module Thrift
UTF8_ENCODING = "utf-8"
class BinaryProtocol
def write_string(str)
write_i32(str.bytesize)
trans.write(str)
end
end
class HTTPClientTransport < BaseTransport
def write(buf)
puts "write"
@outbuf << buf.force_encoding(UTF8_ENCODING)
end
end
class FramedTransport < BaseTransport
def write(buf,sz=nil)
buf.force_encoding(UTF8_ENCODING)
return @transport.write(buf) unless @write
@wbuf << (sz ? buf[0...sz] : buf)
end
def flush
return @transport.flush unless @write
out = [@wbuf.length].pack('N')
out.force_encoding(UTF8_ENCODING)
out << @wbuf
@transport.write(out)
@transport.flush
@wbuf = ''
end
end
class BufferedTransport < BaseTransport
def write(buf)
@wbuf << buf.force_encoding(UTF8_ENCODING)
end
def flush
if @wbuf != ''
@wbuf.force_encoding(UTF8_ENCODING)
@transport.write(@wbuf)
@wbuf = ''
end
@transport.flush
end
end
end
While I can't vouch for the production worthiness of the above code I can say it at least gets me past an aggravating hurdle.