最近、Thrift を使用して Python を Java に接続しようとしました。
Python (PyPy) でサーバーを作成しました。動作する参照クライアントも作成しました。
次に、「接続拒否」例外のみを生成する Java クライアントを作成しました。
これの何が問題なのですか?(最近、この問題を特徴とするクローズド イシューも見つけましたhttps://issues.apache.org/jira/browse/THRIFT-1888 )
PS。Thrift 0.9 リリース、PyPy 2.0 ベータ 2、Java 1.7.0_11 を使用
テスト。倹約
namespace java com.test
namespace python test
service TestPing {
void ping()
}
Python サーバー コード
class TestPingHandler:
def ping(self):
pass
handler = TestPingHandler()
processor = TestPing.Processor(handler)
transport = TSocket.TServerSocket(port=9091)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
print 'Starting the server...'
server.serve()
print 'done.'
Java クライアント コード
TTransport transport;
transport = new TSocket("localhost", 9091);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
client = new TestPing.Client(protocol);
client.ping();
Python クライアント コードの参照
transport = TSocket.TSocket('localhost', 9091)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = TestPing.Client(protocol)
transport.open()
client.ping()
transport.close()