Reputation: 1
My Adnroid app is running on AVD and Cassandra server is running on Windows 7 (same machine) Below is the code snippet I have used for connecting to Cassandra client.
TTransport tr = new TFramedTransport(new TSocket("127.0.0.1", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
I have tried to debug; it creates the socket with isClose() = 'false' (that means socket is open) but further it fails to connect (TSocket.open())
-------------------------Code from org.apache.thrift.transport.TSocket--------------------
try {
socket_.connect(new InetSocketAddress(host_, port_), timeout_);
inputStream_ = socket_.getInputStream();
outputStream_ = socket_.getOutputStream();
} catch (IOException iox) {
close();
throw new TTransportException(TTransportException.NOT_OPEN, iox);
It seems to be a problem with cross platform and the Windows OS (as Android apps are on Linux). Is there any better way I can connect to Cassandra server from Android app ? You help and time is higly appreciated.
Thanks Randeep
Upvotes: 0
Views: 694
Reputation: 109237
I don't know what are you doing, (Its solved your problem or not) But one thing is getting clear that Android emulator doesn't understand localhost
or 127.0.0.1
, If you want to connect localhost then either use a public IP
of system or 10.0.2.2
(for localhost)..
Upvotes: 4