4

I have a server with two network interfaces. Cassandra is listening on a dedicated internal database network on eth1 (not accessable from outside). So I do my tunnel like this:

ssh -f -N -L9161:192.XXX.XXX.200:9160 user@192.YYY.YYY.200 -P 9922

Where XXX is the internal database network and YYY is the network where ssh is listening. When I try to cqlsh localhost 9161 I get the follwing exception:

Connection error: ('Unable to connect to any servers', {'localhost': ConnectionShutdown('Connection <AsyncoreConnection(139691023521360) localhost:9161 (closed)> is already closed',)})

But when I telnet localhost 9161 I get successfully a telnet shell. And of course cassandra is running.

Any ideas how I can get my tunnel to work?

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
KIC
  • 145
  • 1
  • 6

2 Answers2

8

You need to proxy both port 9160 (Cassandra Client port) and port 9042 (CQL native port). Either run two terminals or make the ssh client go background with these flags:

ssh -f -N -q -L 9042:192.XXX.XXX.200:9042 user@192.YYY.YYY.200 -P 9922
ssh -f -N -q -L 9160:192.XXX.XXX.200:9160 user@192.YYY.YYY.200 -P 9922

Now you should be able to connect with cqlsh on default port at localhost. Localhost is default host as well.

cqlsh -u [username] -p [password]
Sven
  • 181
  • 3
  • I can telnet both ports but the cqlsh error msg is still the same – KIC Mar 03 '15 at 16:46
  • And both ssh sessions are running? Are you allowed to port forward on the proxy machine? – Sven Mar 03 '15 at 23:33
  • So what is the port supplied to `cqlsh` on the command-line ? What if I want to have two tunnels to separate cassandra instances ? do I have to use different localhost addresses or something ? – b0fh May 13 '15 at 09:13
0

I had the same issue, and it ended up looking like an incompatibiltiy between cqlsh 5.0.1 (bundled with Cassandra 2.1.4, installed from their official APT repository) and our old Cassandra 2.0.14 nodes (shipped with DataStax).

Temporarily downgrading to the cqlsh 4.1 bundled with datastax solved the issue.

b0fh
  • 3,313
  • 1
  • 20
  • 32