1

I've installed GridDB on Ubuntu. I use 2 computers: first computer is used as GridDB server, second as java Client and when i try to connect to GriDB from second computer it throws Exception, but when I run java code in server side it works completely fine. What's the problem? I use this tutorial.

Here is simple java code:

import java.util.Arrays;
import java.util.Properties;

import com.toshiba.mwcloud.gs.Collection;
import com.toshiba.mwcloud.gs.GSException;
import com.toshiba.mwcloud.gs.GridStore;
import com.toshiba.mwcloud.gs.GridStoreFactory;
import com.toshiba.mwcloud.gs.Query;
import com.toshiba.mwcloud.gs.RowKey;
import com.toshiba.mwcloud.gs.RowSet;


// Operaton on Collection data
public class Sample1 {

    static class Person {
        @RowKey String name;
        boolean status;
        long count;
        byte[] lob;
    }

    public static void main(String[] args) throws GSException {

        // Get a GridStore instance
        Properties props = new Properties();
        props.setProperty("notificationAddress", "239.0.0.1");
        props.setProperty("notificationPort", "31999");
        props.setProperty("clusterName", "defaultCluster");
        props.setProperty("user", "admin");
        props.setProperty("password", "admin");
        GridStore store = GridStoreFactory.getInstance().getGridStore(props);

        // Create a Collection (Delete if schema setting is NULL)
        Collection<String, Person> col = store.putCollection("col01", Person.class);


    }

}

here is Exception, when i try to connect from second computer:

com.toshiba.mwcloud.gs.common.GSConnectionException: [145028:JC_BAD_CONNECTION] Failed to connect (address=/127.0.1.1:10001, reason=Connection refused: connect)
    at com.toshiba.mwcloud.gs.subnet.NodeConnection.<init>(NodeConnection.java:142)
    at com.toshiba.mwcloud.gs.subnet.NodeConnectionPool.resolve(NodeConnectionPool.java:163)
    at com.toshiba.mwcloud.gs.subnet.NodeResolver.updateConnectionAndClusterInfo(NodeResolver.java:644)
    at com.toshiba.mwcloud.gs.subnet.NodeResolver.prepareConnectionAndClusterInfo(NodeResolver.java:529)
    at com.toshiba.mwcloud.gs.subnet.NodeResolver.getPartitionCount(NodeResolver.java:205)
    at com.toshiba.mwcloud.gs.subnet.GridStoreChannel$5.execute(GridStoreChannel.java:2106)
    at com.toshiba.mwcloud.gs.subnet.GridStoreChannel.executeStatement(GridStoreChannel.java:1675)
    at com.toshiba.mwcloud.gs.subnet.GridStoreChannel.executeResolver(GridStoreChannel.java:1912)
    at com.toshiba.mwcloud.gs.subnet.GridStoreChannel.resolvePartitionId(GridStoreChannel.java:2103)
    at com.toshiba.mwcloud.gs.subnet.SubnetGridStore.putContainer(SubnetGridStore.java:968)
    at com.toshiba.mwcloud.gs.subnet.SubnetGridStore.putCollection(SubnetGridStore.java:1024)
    at com.toshiba.mwcloud.gs.subnet.SubnetGridStore.putCollection(SubnetGridStore.java:787)
    at com.toshiba.mwcloud.gs.subnet.SubnetGridStore.putCollection(SubnetGridStore.java:98)
    at pac.Main.main(Main.java:39)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.toshiba.mwcloud.gs.subnet.NodeConnection.<init>(NodeConnection.java:129)
    ... 13 more
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260

2 Answers2

1

Caused by: java.net.ConnectException: Connection refused: connect

The problem is that the server is not accepting connections from the second machine. This could be due to a number of things. The most likely are:

  • Your server is not listening for requests on its external IP address. (For example, the DB may be listening on 127.0.0.1 only.) On the server, check what services are listening on the server's external IP address; e.g. https://www.tecmint.com/find-listening-ports-linux/.

  • Your client may be configured to talk to the wrong server, or to use the wrong port.

  • Firewalls. (Though the normal firewall behavior would be to drop the connection packets, leading to a different exception.)

There are other possibilities, but the above should be enough to get you started.


If the above haven't identified the problem, you will need to resort to things like:

  • Check to see what happens when you connect to that database server / port using a TCP diagnostic tool. Does it connect at the TCP level?

  • Use a network packet sniffer to see what happens to the TCP packets when the client tries to connect to the database.

  • Check your route tables and IP tables for strange routing rules. If you are using a virtual machine, check at the hypervisor level too.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • 1)I've checked what addrress GridDB is listening, GridDB listens on address 0.0.0.0 only , does it mean that second computer can't connect to GridDB? 2)I've tried different configurations for my client and all of them throw exceptions. 3) I've disabled FireWalls, but it didn't help what did i do wrong? – dsfsdvbcvbc Jan 15 '20 at 21:09
1

239.0.0.1 is a multicast address. And often it needs to do some additional steps with OS, router settings to enable multicast.

So it makes sense to check if multicast is enabled: https://serverfault.com/questions/294207/how-can-i-test-multicast-udp-connectivity-between-two-servers

And also you could check that the IP/port, with which the GridDB node is registered in the cluster, is accessible. The IP address can be obtained with next command:

$ gs_stat -u admin/admin
Aleh.R
  • 11
  • 2