I am trying to use the bigtable emulator from gcloud beta emulators.
I launch the emulator, grab the hostname (localhost) and port (in this instance 8885)
gcloud beta emulators bigtable start
Executing: /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/bigtable-emulator/cbtemulator --host=localhost --port=8885
I am trying to connect to the emulator from a java test client,
here is what I provide:
Configuration conf = BigtableConfiguration.configure(projectId, instanceId);
if(!Strings.isNullOrEmpty(host)){
conf.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, host);
conf.set(BigtableOptionsFactory.BIGTABLE_PORT_KEY, Integer.toString(port));
}
connection = BigtableConfiguration.connect(configuration);
try (Table table = connection.getTable("tName")){
table.put(<Put instance>);
}
When I execute the test code I get:
16:36:37.369 [bigtable-batch-pool-1] INFO com.google.cloud.bigtable.grpc.async.AbstractRetryingRpcListener - Retrying failed call. Failure #1, got: Status{code=UNAVAILABLE, description=null, cause=java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885}
java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885
I am using the library: com.google.cloud.bigtable:bigtable-hbase-1.2:0.9.1
Any idea of what I am doing wrong ?
Thanks !
You need one additional config property to be set:
conf.set(BigtableOptionsFactory.BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true);
Also, from the log message it looks like it's trying to connect to an IPv6 address, which I don't think will work. Double-check that host is a valid IPv4 address.
The java client will make this easier to do in the near future.
Now you can set
configuration.set(BigtableOptionsFactory.BIGTABLE_EMULATOR_HOST_KEY,<HOST:PORT>); to connect to an emulator.
Also "https://github.com/googleapis/java-bigtable/tree/master/google-cloud-bigtable-emulator" can be used to start emulators programmatically for tests etc.
Related
I have a remote MongoDB that I need to connect to. I have all the credentials, but when trying to connect from gradle with this.mongoClient = MongoClients.create(dbConnectionString);, I get following error:
java.io.UncheckedIOException: java.net.SocketException: Network is unreachable
at java.base/sun.nio.ch.DatagramSocketAdaptor.disconnect(DatagramSocketAdaptor.java:136)
at java.base/java.net.DatagramSocket.disconnect(DatagramSocket.java:393)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.doUdpQuery(DnsClient.java:437)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:214)
at jdk.naming.dns/com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at jdk.naming.dns/com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at java.naming/javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:171)
at com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:114)
at com.mongodb.ConnectionString.<init>(ConnectionString.java:381)
at com.mongodb.client.MongoClients.create(MongoClients.java:61)
at io.my.package.dbsetup.DatabaseService.<init>(DatabaseService.java:28)
When I print the connectionString and run mongo $connectionString in terminal, I can connect with no problems. Even MongoDB Compass works. It's just Gradle that doesn't.
My colleague with Ubuntu (I have a Mac) can connect with no issues when running the same code. What could be causing this? Firewall is off.
Turns out I needed to use different Java version - 16 didn't work, but I had luck with 8
I'm using couchbase-client 2.3.2 for Java and Couchbase server Community 4.0
So I'm experimenting with running Couchbase on non-standard ports using the documentation at Couchbase website
I've managed to start Couchbase using these alternate ports but I've only managed to change some of the ports in the java client, here's my code:
final CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
.bootstrapCarrierDirectPort(21210)
.bootstrapHttpDirectPort(9091)
.build();
return CouchbaseCluster.create(env, "10.0.2.15");
My program is able to connect to couchbase and so some things, however I still need to change the view port (default 8092) and the query port (default 8093) in the client. as a result I'm met with these errors:
2016-09-30 14:03:49.696 [] WARN c.c.c.c.e.Endpoint - [null][QueryEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS: ! java.net.ConnectException: Connection refused: /10.0.2.15:8093
2016-09-30 14:03:52.077 [] WARN c.c.c.c.e.Endpoint - [null][ViewEndpoint]: Could not connect to endpoint, retrying with delay 2048 MILLISECONDS: ! java.net.ConnectException: Connection refused: /10.0.2.15:8092
So the client still tries to connect to 8092 and 8093 when in fact I've changed those to 9092 and 9093
From the JavaDoc on 2.3.4 (http://docs.couchbase.com/sdk-api/couchbase-java-client-2.3.4/), I believe what you want is this:
DefaultCouchbaseEnvironment.Builder viewEndpoints(int viewServiceEndpoints)
Even though it's completely undocumented, you need to add those ports to static_config as well:
{capi_port, 9092}.
{query_port, 9093}.
and then it works, hope someone at couchbase sees this and updates their documentation :)
Today I encountered the following problem. When connecting to a database, the following error.Appeal to the remote database by connecting through vpn.
Added necessary firewall ports and even tried to disconnect its(did not help)
Added record to $JAVA_HOME/jre/lib/security/java.policy
grant codeBase "file:/-" {
permission java.security.AllPermission;
};(did not help)
If trying to connect with same data through sql management studio, it works and there is access. from the development environment no connection
Example(string connection = jdbc:sqlserver://DEVMSSQL14.test.com:1433;SCHEMA=test;DATABASENAME=test, sql managment studia = DEVMSSQL14.test.com,1433)
on another computer it works without problems, the same version of the project
It remains only to "Permission denied: connect".Maybe somebody faced with similar
Error:
The TCP/IP connection to the host DEVMSSQL14.test.com, port 1433 has failed. Error: "Permission denied: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
In the error message, you have shown like DEVMSSQL14.test.com, 1433 has failed.
I believe, it is correct. I dont think. this host name is correct. which says "TEST" as domain
Open the cmd, try to ping DEVMSSQL14.test.com
Success case :
If you are able to ping, then make sure the services are running for sql in services
Failure case:
Get the right host name to establish the connection
When i tried, i got this message, because i may be out of network.
Pinging DEVMSSQL14.test.com [208.64.121.161] with 32 bytes of data:
Request timed out.
Request timed out.
Try setting a System Property while running the code.
The catch is to introduce this line in code: System.setProperty("java.net.preferIPv4Stack", "true");
Or to pass it in VM option: -Djava.net.preferIPv4Stack=true
I'm trying to start Cassandra using code, and I can't connect to it. When I telnet to port 7000, it does connect, but when I try to connect to 9042 (the "native transport" port) I get a "connection refused". So, somehow, the native transport isn't happening.
My startup code:
File file = new File(home, "etc/cassandra.yaml");
System.setProperty("cassandra.config", "file:" + file.getPath());
CassandraDaemon cassandra = new CassandraDaemon();
cassandra.init(null);
My cassandra.yaml contains:
start_native_transport: true
native_transport_port: 9042
The logs indicate that Cassandra is starting. I see no reference in the logs to any native transport, even when the log level is set to DEBUG. No references to port 9042.
I'm on Windows. I don't think it's a firewall issue because I'm trying to connect from localhost.
Any ideas?
Have you tried calling the .start method?
I've implemented an Embedded Cassandra Server in Achilles, example of working code here: https://github.com/doanduyhai/Achilles/blob/master/achilles-core/src/main/java/info/archinnov/achilles/embedded/CassandraEmbedded.java
CassandraDaemon cassandraDaemon = new CassandraDaemon();
cassandraDaemon.activate();
java.sql.SQLNonTransientConnectionException: java.net.ConnectException :
Error connecting to server localhost on port 1527 with message Connection refused: connect.
I am using Netbeans.
If I go to the Services Tab and rightclick Java DB and start Server it works fine.
How can I do this programmaticly at Runtime. I just need whatever method will start the Java DB Server.
Have a look at how to use JavaDB with a desktop application. They describe how to start it programmatically there.
You need to start the NetworkServerControl additional documentation can be found here
NetworkServerControl server = new NetworkServerControl(InetAddress.getByName("localhost"), port);