Reputation: 9419
I have created a server and a client in thrift. Then I started the thrift server on my computer. I ran the client on another computer in LAN using my machines IP address.
public class ArithmeticClient {
private void invoke() {
TTransport transport;
try {
transport = new TSocket("192.168.0.232"/*this is my machine,which the sever runs' IP address*/, 7911);
TProtocol protocol = new TBinaryProtocol(transport);
ArithmeticService.Client client = new ArithmeticService.Client(protocol);
transport.open();
long addResult = client.add(100, 200);
System.out.println("Add result: " + addResult);
long multiplyResult = client.multiply(20, 40);
System.out.println("Multiply result: " + multiplyResult);
transport.close();
} catch (TTransportException e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
ArithmeticClient c = new ArithmeticClient();
c.invoke();
}
}
And I got an Error
org.apache.thrift.transport.TTransportException: java.net.NoRouteToHostException: No route to host
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at ArithmeticClient.invoke(ArithmeticClient.java:18)
at ArithmeticClient.main(ArithmeticClient.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 7 more
How can I solve this thing.
Both computer runs Fedora. versions are different (17 and 19)
Upvotes: 1
Views: 3627
Reputation: 13411
public class NoRouteToHostException extends SocketException
Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the remote host cannot be reached because of an intervening firewall, or if an intermediate router is down.
That's what the docs say, and what I would guess. Could that be the reason? What happens if you try to ping or telnet that machine?
Upvotes: 1