I am writing a JBoss EAR application that needs to query the local JBoss server it is running on for status of deployments. I am running JBoss as standalone. I am able to query the JBoss server easily using the JBoss-CLI, but using the API with the 'ModelControllerClient', I am getting a "connection refused" error. My firewall is completely disabled, and I am pointing at localhost, so I am not sure what the problem could be.
Here is the code I am running:
public static void GetStatus() throws Exception{
ModelNode operation = new ModelNode();
operation.get( "address" ).add( "deployment", "*" );
operation.get( "operation" ).set( "read-attribute" );
ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("127.0.0.1"), 9990);
ModelNode result = client.execute( new OperationBuilder(operation).build() );
List<ModelNode> deployments = result.get( "result" ).asList();
String deploymentName;
// finally we can iterate and get the deployment names.
for ( ModelNode deployment : deployments ) {
deploymentName = deployment.get( "result" ).asString();
System.out.println( "deploymentName = " + deploymentName );
}
}
... and here is the error I receive when this method is called:
java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to remote://localhost:9990. The connection timed out
If I run the netstat -tuna command, I see that I am listening to 0:0:0:0:9990
Thanks!
Try with starting server on localhost instead of 0.0.0.0. Also refer sample example from http://middlewaremagic.com/jboss/?p=2676
Related
need your help,
I need to connect to AWS Aurora Postgresql using liquibase, it's already configured for local machine, and works fine, but have issues with ssh configuration to it.
I'm using id 'org.hidetake.ssh' version '2.10.1', and id 'org.liquibase.gradle' version '2.0.4'
I'm able to run command directly on host machine, like getting date execute ('date') below, but have no idea why liquibase fails with
Unexpected error running Liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgresql://xxxx.rds.amazonaws.com:5432/postgres with driver org.postgresql.Driver. The connection attempt failed.
here is my build.gradle setting:
ssh.settings {
knownHosts = allowAnyHosts
logging = 'stdout'
identity = file("${System.properties['user.home']}/myfolder/.ssh/id_rsa")}
remotes {
dev {
host = 'xxx.xxx.xxx.xxx'
port = 22
user = 'ec2-user'
identity = file("${System.properties['user.home']}/myfolder/.ssh/id_rsa")
}
}
ssh.run {
session(remotes.dev) {
forwardLocalPort port: 5432, hostPort: 5432
execute ('date')
liquibase {
activities {
main {
//changeLogFile changeLog
url 'jdbc:postgresql://xxxx.rds.amazonaws.com:5432/postgres'
username feedSqlUserDev
password feedSqlUserPasswordDev
logLevel 'debug'
}
}
}
}
}
Could you please help me with it, what am I doing wrong?
Also had to connect to SSH bastion host before running liquibase updates. My solution is based on https://github.com/int128/gradle-ssh-plugin/issues/246 answer by the plugin author.
Here is my setup:
ssh.settings {
knownHosts = allowAnyHosts
logging = 'stdout'
identity = file("${System.properties['user.home']}/.ssh/id_rsa")
}
remotes {
bastion {
host = '<hostname>'
user = '<username>'
}
}
liquibase {
activities {
main {
changeLogFile '...'
url 'jdbc:postgresql://localhost:5438/***'
username '***'
password '***'
driver 'org.postgresql.Driver'
}
}
}
task('sshTunnelStart') {
doFirst {
project.ext.ready = new CountDownLatch(1)
project.ext.done = new CountDownLatch(1)
Thread.start {
ssh.run {
session(remotes.bastion) {
forwardLocalPort port: 5438,
host: '<real db hostname>',
hostPort: 5432
project.ready.countDown()
project.done.await(5, TimeUnit.MINUTES) // liquibase update timeout
}
}
}
ready.await(10, TimeUnit.SECONDS) // start tunnel timeout
}
}
task('sshTunnelStop') {
doLast {
// teardown tunnel
project.done.countDown()
}
}
update.dependsOn(sshTunnelStart)
update.finalizedBy(sshTunnelStop)
Note that in liquibase config I use localhost:5438 as it is a local port forwarded to the remote. Later the same port is used in forwardLocalPort as a 'port' parameter. 'host' parameter is set to the remote database host, and 'hostPort' is accordingly the database port. The last part of the config adds dependencies between tasks to liquibase update and start/stop the tunnel.
I'm new to akka and wanted to connect two PC using akka remotely just to run some code in both as (2 actors). I had tried the example in akka doc. But what I really do is to add the 2 IP addresses into config file I always get this error?
First machine give me this error:
[info] [ERROR] [11/20/2018 13:58:48.833]
[ClusterSystem-akka.remote.default-remote-dispatcher-6]
[akka.remote.artery.Association(akka://ClusterSystem)] Outbound
control stream to [akka://ClusterSystem#192.168.1.2:2552] failed.
Restarting it. Handshake with [akka://ClusterSystem#192.168.1.2:2552]
did not complete within 20000 ms
(akka.remote.artery.OutboundHandshake$HandshakeTimeoutException:
Handshake with [akka://ClusterSystem#192.168.1.2:2552] did not
complete within 20000 ms)
And second machine:
Exception in thread "main"
akka.remote.RemoteTransportException: Failed to bind TCP to
[192.168.1.3:2552] due to: Bind failed because of
java.net.BindException: Cannot assign requested address: bind
Config file content :
akka {
actor {
provider = cluster
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.3"
canonical.port = 0
}
}
cluster {
seed-nodes = [
"akka://ClusterSystem#192.168.1.3:2552",
"akka://ClusterSystem#192.168.1.2:2552"]
# auto downing is NOT safe for production deployments.
# you may want to use it during development, read more about it in the docs.
auto-down-unreachable-after = 120s
}
}
# Enable metrics extension in akka-cluster-metrics.
akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]
# Sigar native library extract location during tests.
# Note: use per-jvm-instance folder when running multiple jvm on one host.
akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native
First of all, you don't need to add cluster configuration for AKKA remoting. Both the PCs or nodes should be enabled remoting with a concrete port instead of "0" that way you know which port to connect.
Have below configurations
PC1
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.3"
canonical.port = 19000
}
}
}
PC2
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.4"
canonical.port = 18000
}
}
}
Use below actor path to connect any actor in remote from PC1 to PC2
akka://<PC2-ActorSystem>#192.168.1.4:18000/user/<actor deployed in PC2>
Use below actor path to connect from PC2 to PC1
akka://<PC2-ActorSystem>#192.168.1.3:19000/user/<actor deployed in PC1>
Port numbers and IP address are samples.
I have created a service for getting the entity manager in a command
I don't understand why I can use the entity manager in regular Controller and not in my Command.
I have declared my service in "service.yml"
common.doctrine:
class: AppBundle\Services\GetDoctrineService
arguments: [ '#doctrine.orm.entity_manager' ]
public: true
I wrote it in "GetDoctrineService.php"
<?php
namespace AppBundle\Services;
use Doctrine\ORM\EntityManager;
class GetDoctrineService
{
protected $em;
public function __construct(\Doctrine\ORM\EntityManager $em)
{
$this->em = $em;
}
public function getRepository(string $repo) {
return $this->em->getRepository($repo);
}
}
In my command, I am importing it and calling it in the "Command way"
$em = $this->getApplication()->getKernel()->getContainer()->get('common.doctrine');
$foo = $em->getRepository(Entity::FOO)->findAll();
I changed the db host to "localhost" in "parameters.yml"
# This file is auto-generated during the composer install
parameters:
#database_host: db-name
database_host: localhost
When I installed postgres with a command, the file "pg_hba.conf" wasn't created (I am working with Ubuntu)
I have this error while i use my command :
Message: "An exception occured in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?"
The problem was in the configuration files:
using 'localhost' was a mistake: we should have use the dn-name for the host
I decided to play with lapis - https://github.com/leafo/lapis, but the application drops when I try to query the database (PostgreSQL) with the output:
2017/07/01 16:04:26 [error] 31284#0: *8 lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
[C]: in function 'require'
/usr/local/share/lua/5.1/lapis/init.lua:15: in function 'serve'
content_by_lua(nginx.conf.compiled:22):2: in function , client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"
The code that causes the error:
local db = require("lapis.db")
local res = db.query("SELECT * FROM users");
config.lua:
config({ "development", "production" }, {
postgres = {
host = "0.0.0.0",
port = "5432",
user = "wars_base",
password = "12345",
database = "wars_base"
}
})
The database is running, the table is created, in table 1 there is a record.
What could be the problem?
Decision: https://github.com/leafo/lapis/issues/556
You need to specify the right server IP in the host parameter.
The IP you have specified 0.0.0.0 is not a valid one, and normally it is used when you specify a listen address, with the meaning of "every address".
Usually you can use the '127.0.0.1' address during development.
I have a cluster with 2 workers and 1 master. the cluster is implemented with Akka and Scala.
When i killed the worker and try to run it again with the following command:
java -Xms3500M -Xmx3500M -Dlog_file_name=worker1
"-Dconfig.file=F:\cluster\application.conf" -cp cluster.jar
knowmail.Worker worker1 2551
I get the following error:
Connection refused
Association with remote system
[akka.tcp://ClusterSystem#xxxxxx:2552] has failed, address is now
gated for [5000] ms. Reason: [As
kka.tcp://ClusterSystem#xxxx:2552]] Caused by: [Connection
refused: no further information: /xxxx:2552]
a configuration of cluster:
remote {
log-remote-lifecycle-events = off
log-received-messages = on
log-sent-messages = on
netty.tcp {
hostname = "xxxxxx"
port = 8888
bind-hostname = 0.0.0.0
bind-port = 8888
}
}
cluster {
seed-nodes = [
"akka.tcp://ClusterSystem#xxxxx:2551",
"akka.tcp://ClusterSystem#xxxxxx:2552"]
auto-down-unreachable-after = 20s
}
http.client.parsing.max-content-length = infinite
}
Did anyone encountered this error and solved it?
This happens when I start one of the seed nodes/workers before the other seed node has been started.
So one seed node is looking for the other and reports the following error of:
akka.tcp://ClusterSystem#10.5.2.10:2552] has failed, address is now
gated for [5000] ms.