Apache Thrift로 작업하고 있습니다. TTransportException 예외가 발생하는 동안 내 코드는 괜찮아 보입니다. 여기 내 드리프트 서버 코드입니다 :TTransportException Apache Thrift와 작업하는 동안 예외가 발생했습니다.
private TNonblockingServerSocket socket;
/**
* @breif Store processor instance.
*/
private PringService.Processor processor;
/**
* Store server instance.
*/
private TServer tServer;
/**
*
* @breif A handle to the unique Singleton instance.
*/
static private ThriftServer _instance = null;
/**
* @breif The unique instance of this class.
* @throws TTransportException
*/
static public ThriftServer getInstance() throws TTransportException {
if (null == _instance) {
_instance = new ThriftServer();
}
return _instance;
}
/**
* @breif A Ctor for ThriftServer. Initialize all members.
* @throws TTransportException
*/
private ThriftServer() throws TTransportException {
socket = new TNonblockingServerSocket(Config.THRIFT_PORT);
processor = new PringService.Processor(new Handler());
THsHaServer.Args args = new THsHaServer.Args(socket);
args.processor(processor);
args.transportFactory(new TFramedTransport.Factory());
args.inputProtocolFactory(new TBinaryProtocol.Factory());
args.outputProtocolFactory(new TBinaryProtocol.Factory());
tServer = new THsHaServer(args);
/*tServer = new THsHaServer(processor, socket,
new TFramedTransport.Factory(),
new TFramedTransport.Factory(),
new TBinaryProtocol.Factory(),
new TBinaryProtocol.Factory());*/
}
/**
* @breif main method
* @param args the command line arguments
* @throws TTransportException
*/
public static void main(String[] args) throws TTransportException {
// To Run it directly from PringCore.jar, else use SmsProcessor Helper functionality
ThriftServer server = new ThriftServer();
server.execute(args);
}
@Override
/**
* @breif Starts the execution.
*/
protected void execute(String[] args) {
if (db != null) {
db.close();
}
tServer.serve();
}
개인 정적 클래스 처리기 { ...... } }
PringService.Iface를 구현 그리고 이것은 내 중고품 클라이언트입니다 :
TTransport transport;
try {
transport = new TSocket("localhost", Config.THRIFT_PORT);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
PringService.Client client = new PringService.Client(protocol);
String result = client.importPringer(2558456, true);
System.out.println("Result String is ::"+result);
transport.close();
} catch (TTransportException e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
}
Thrift 서버를 실행 한 후 절약 클라이언트를 실행할 때 다음 예외가 발생합니다.
org.apache.thrift.transport.TTransportException
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
드리프트 서버 또는 클라이언트에서 전송 Sockt/레이어가 잘못 일치합니까? 아니면 뭔가 다른 것이 있습니까? 당신이 TNonblockingServerSocket
를 사용할 때 안내 : 사전에
덕분에
감사를 도와. 이것은 일했다 :) –