Categories
Database Development

Host machine app unable to query guest machine cassandra database

Environment

Host:*
Ubuntu 18.04 Desktop 64Bit
Visual Studio Code + CassandraCSharpDriver

Guest:
Ubuntu 18.04 Server
Java and Cassandra installed
Single node
Replication 1
Consistency 1
Cassandra service running
keyspace and table created
Data entered into table
Virtual Box network for guest set to Bridge.

The problem

When I run the code on the host machine, I get an error:

user@desktop:~/Desktop/vsc$ dotnet run
Unhandled exception. Cassandra.NoHostAvailableException: All hosts tried for query failed (tried 192.168.0.15:9042: SocketException 'No route to host')
   at Cassandra.Connections.ControlConnection.Connect(Boolean isInitializing)
   at Cassandra.Connections.ControlConnection.InitAsync()
   at Cassandra.Tasks.TaskHelper.WaitToCompleteAsync(Task task, Int32 timeout)
   at Cassandra.Cluster.Cassandra.SessionManagement.IInternalCluster.OnInitializeAsync()
   at Cassandra.ClusterLifecycleManager.InitializeAsync()
   at Cassandra.Cluster.Cassandra.SessionManagement.IInternalCluster.ConnectAsync[TSession](ISessionFactory`1 sessionFactory, String keyspace)
   at Cassandra.Cluster.ConnectAsync(String keyspace)
   at Cassandra.Tasks.TaskHelper.WaitToComplete(Task task, Int32 timeout)
   at Cassandra.Tasks.TaskHelper.WaitToComplete[T](Task`1 task, Int32 timeout)
   at Cassandra.Cluster.Connect(String keyspace)
   at HelloWorld.Program.Main(String[] args) in /home/userone/Desktop/vsc/Program.cs:line 15
user@desktop:~/Desktop/vsc$ 

However, I can ping to the guest machine from the host machine without any issues:

ping 192.168.0.15

I can also ping from the guest machine to the host machine without any issues.


What I have tried

On a Windows machine where the machine runs the code and cassandra on the same host without using a VM, the code and the database work fine as the code is able to insert and select from with database without any issues.


Question

How do I configure the VM guest so I can get the code on the host machine to connect to the cassandra database? I am assuming the issue is happening because the VM is not configured properly?

Leave a Reply

Your email address will not be published. Required fields are marked *