I have mongo db running in a remote server (debian) with authentication on. I need to connect to it with UMongo (UI tool for mongodb) from my local machine (windows) to visualize the data. I have not opened mongodb port in server machine, but have made a ssh tunnel from my localhost:9999 to the mongodb-host:port. As connection uri in UMongo, i have given
[username]:[password]#localhost:9002
(also tried with [username]:[password]#localhost:9002/dbname)
and tried to connect. It shows the database but doesn't authenticate, it throws authentication error. I have made sure that the credentials given are correct. Wondering whether the credentials are not being passed to the mongodb server properly with ssh tunnelling.
Update: I restarted mongo server with authentication disabled. After that i tried to access the remote mongo shell. When i tried with mongo --port 9002, it gave the below error:
MongoDB shell version: 2.4.4
connecting to: 127.0.0.1:9002/test
Thu Sep 05 22:55:21.107 Socket recv() errno:10054 An existing connection was forcibly
closed by the remote host. 127.0.0.1:9002
Thu Sep 05 22:55:21.107 SocketException: remote: 127.0.0.1:9002 error: 9001 socket
exception [1] server [127.0.0.1:9002]
Thu Sep 05 22:55:21.107 DBClientCursor::init call() failed
Thu Sep 05 22:55:21.107 JavaScript execution failed: Error: DBClientBase::findN:
transport error: 127.0.0.1:9002 ns: admin.$cmd query: { whatsmyuri: 1
} at src/mongo/shell/mongo.js:L114
exception: connect failed
But when i tried with mongo --port 9002 --nodb, i was able to get the mongo shell. Then i tried to use mydb which throws the below error:
Thu Sep 05 22:57:43.205 JavaScript execution failed: ReferenceError: db is not defined
at src/mongo/shell/utils.js:L691
Any help would be much appreciated.
Thanks.
Related
I am trying to do distributed load testing on my network. I have two computers running WSL2 and the firewall is turned off on both of them. I am using OpenJDK version 1.8.0_292 on both WSLs. The Jmeter version on both systems is 5.4.2. I have server.rmi.ssl.disable=true in both Jmeter.properties files. I can access the web application when I type 192.168.1.6:4080 in my browser's URL on my computer running on 192.168.1.18.
The jmeter.properties file for the computer running the web application has remote_hosts=192.168.1.18
The jmeter.properties file for the computer that will be the slave machine has server.rmi.localport=4000
One of my Computers is running the web application and will also be running the client (i.e. ./jmeter). In the Jmeter test plan, the HTTP Request Defaults have the server name 192.168.1.6 and the port as 4080. My other computer has the IPv4 address of 192.168.1.18.
I start the slave machine first by entering ./jmeter-server -n -Djava.rmi.server.hostname=192.168.1.18 -X and the following is outputted Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.1.18:4000](local),objID:[-5f7e0f00:17ab805fd23:-7fff, -5246535002214415146]]]
Now I start the client by entering './jmeter -n -t ~/test_plan.jmx -l ~/result.jtl -X -r '. On the slave machine I get
Starting the test on host 192.168.1.18 # Sat Jul 17 22:02:16 PDT 2021 (1626584536943)
Finished the test on host 192.168.1.18 # Sat Jul 17 22:03:25 PDT 2021 (1626584605136)
And on the client machine I get
Creating summariser <summary>
Created the tree successfully using /home/jasperhale/test_plan.jmx
Configuring remote engine: 192.168.1.18
Starting distributed test with remote engines: [192.168.1.18] # Sat Jul 17 22:10:44 PDT 2021 (1626585044116)
Remote engines have been started:[192.168.1.18]
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
The problem is that after the slave finishes, the client does not stop and report results. When I inspect the jmeter-server.log file I get this error message
2021-07-17 22:56:22,545 ERROR o.a.j.s.RemoteListenerWrapper: testStarted(host) on 192.168.1.18
java.rmi.ConnectException: Connection refused to host: 192.168.1.6; nested exception is:
2021-07-17 22:11:50,420 INFO o.a.j.s.DataStrippingSampleSender: Test Ended on 192.168.1.18
2021-07-17 22:11:50,420 INFO o.a.j.s.BatchSampleSender: Test Ended on 192.168.1.18
2021-07-17 22:11:52,481 ERROR o.a.j.s.BatchSampleSender: testEnded(host)
java.rmi.ConnectException: Connection refused to host: 192.168.1.6; nested exception is:
the error message is way bigger but the main issue is the connection refused
the slave machine is making requests from the test_plan. Also mode=Standard in both properties files. The report files I am trying to collect are the aggregate report, view results tree, and summary report. I've been stuck on this for a while, any help is greatly appreciated.
WSL uses a different IPv4 Address and I was getting those addresses by entering ipconfig into a windows command prompt. I tried it on windows not WSL and it worked.
Try explicitly setting client.rmi.localport property on both master and slave machines to some free port which is not used by any other process like:
client.rmi.localport=1234
Double check that you can reach this host and port from the slave using telnet or netcat or whatever command is there
Once you will be able to reach out from the slave to the master and from the master to the slave your distributed setup should start working normally
More information:
Remote hosts and RMI configuration
JMeter Distributed Testing with Docker
Also having JMeter and the system under test running on the same host is not something you should be normally doing, JMeter can be very resource intensive and you may run into a race condition when both JMeter and the system under test will be struggling for the operating system resources (CPU, RAM, etc.) so test results might be inaccurate
I am trying to run a Java 1.8 Update 192 application on an Azure Windows Server 2016 virtual machine which is using the Microsoft SQLServer JDBC 7.2.1.jre8 driver to connect to an SQLServer managed instance database using a user authenticated against an ActiveDirectory instance and running the application as that user i.e. using Authentication=ActiveDirectoryIntegrated.
I am getting the exception:
Caused by: java.util.concurrent.ExecutionException:
com.microsoft.aad.adal4j.AuthenticationException: Server returned HTTP
response code: 401 for URL :
https://xxx/adfs/services/trust/13/windowstransport
at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthTokenIntegrated(SQLServerADAL4JUtils.java:113)
... 26 more Caused by: com.microsoft.aad.adal4j.AuthenticationException: Server returned HTTP
response code: 401 for URL :
https://xxx/adfs/services/trust/13/windowstransport
at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthTokenIntegrated(SQLServerADAL4JUtils.java:106)
... 26 more 3119 [main] INFO zzz - Database connection failed: Failed to authenticate the user in Active Directory
(Authentication=ActiveDirectoryIntegrated).
I am not a .NET developer and have no knowledge of ActiveDirectory authentication configuration, Windows domains etc.
The above exception error messages mean nothing to me. What do they mean ?
I can connect to the database using an SQLServer authenticated user and password but the requirement is to use Authentication=ActiveDirectoryIntegrated.
The following exception indicates that the authentication with ActiveDirectory failed.
com.microsoft.aad.adal4j.AuthenticationException: Server returned HTTP response code: 401 for URL : https://xxx/adfs/services/trust/13/windowstransport
I fixed the issue by explicitly including the driver jar and dll in the command line:
java -cp .;"C:\Program Files\Microsoft JDBC DRIVER 7.2 for SQL Server\sqljdbc_7.2\enu\mssql-jdbc-7.2.2.jre8.jar" -Djava.library.path="C:\Program Files\Microsoft JDBC DRIVER 7.2 for SQL Server\sqljdbc_7.2\enu\auth\x64" -Dlog4j.configuration=file:log4j.properties -jar MyJar.jar
I am using:
com.microsoft.sqlserver.jdbc.SQLServerDataSource ds =
new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
ds.setServerName(dbServerName);
ds.setPortNumber(dbServerPort);
ds.setDatabaseName(dbaseName);
ds.setAuthentication("ActiveDirectoryIntegrated");
Thanks
i am create a java project and i want to use derby data base and and i am configured database and create database with the name of /home/user/TestDB and create a table user and insert 3 to 4 values into it and write a code to get the data from database but when i connect dada base i got connection refuse error, i am use
DB URL : jdbc:derby://localhost:1527/home/user/TestDB
error logs :
java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at test.derby.util.DerbyUtil.getConnecation(DerbyUtil.java:34)
at test.derby.dao.TestDAO.getData(TestDAO.java:20)
at test.derby.dao.TestDAO.main(TestDAO.java:39)
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
at org.apache.derby.client.am.Connection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
... 6 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
i think you are not start your derver server in specific port which you are using. you need to start server using below command on localhost with default port 1527
startNetworkServer -h 0.0.0.0
if you want to change the port you can use below command :
startNetworkServer -p 3301 // new port number
for more you can refer below link;
http://www.vogella.com/tutorials/ApacheDerby/article.html
may be this error occur because of following reasons:
1) Firewall is not permitted for host-port combination
2) Client and Server, either or both of them are not in the network.
3) The server is running but not listening on the port, a client is trying to connect.
4) Server is not running.
5) Incorrect protocol in Connection String
This error occurs just because your database is not connected.
NETBEANS
Go to Services>Database>Java DB>(right click)
After that simply right click on your database and connect database.
Best Solution
To execute the database program
Step 1:
First database server needs to be started
Open a command shell and change to a directory that will hold the database
files(in this following example the database going to stored in
D:\java2019\Database)
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\startNetworkServer“
Wed Mar 13 10:36:36 IST 2019 : Security manager installed using the Basic server security policy.
Wed Mar 13 10:36:37 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527
The default port number is 1527 we can also change the port number by the following
cmd
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\startNetworkServer" -p 1567
Wed Mar 13 10:46:33 IST 2019 : Security manager installed using the Basic server security policy.
Wed Mar 13 10:46:33 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1567
Step2:
compile and execute the java program
Open another command shell and change to a directory that will hold the database files. set the classpath for derbyrun.jar
set classpath=".;C:\Program Files\Java\jdk1.8.0_66\db\lib\derbyrun.jar”
Step3:
Finally the database server needs to be stopped
Open another command shell and change
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\stopNetworkServer"
Wed Mar 13 10:56:04 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) shutdown
i am create a java project and i want to use derby data base and and i am configured database and create database with the name of /home/user/TestDB and create a table user and insert 3 to 4 values into it and write a code to get the data from database but when i connect dada base i got connection refuse error, i am use
DB URL : jdbc:derby://localhost:1527/home/user/TestDB
error logs :
java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at test.derby.util.DerbyUtil.getConnecation(DerbyUtil.java:34)
at test.derby.dao.TestDAO.getData(TestDAO.java:20)
at test.derby.dao.TestDAO.main(TestDAO.java:39)
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
at org.apache.derby.client.am.Connection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
... 6 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
i think you are not start your derver server in specific port which you are using. you need to start server using below command on localhost with default port 1527
startNetworkServer -h 0.0.0.0
if you want to change the port you can use below command :
startNetworkServer -p 3301 // new port number
for more you can refer below link;
http://www.vogella.com/tutorials/ApacheDerby/article.html
may be this error occur because of following reasons:
1) Firewall is not permitted for host-port combination
2) Client and Server, either or both of them are not in the network.
3) The server is running but not listening on the port, a client is trying to connect.
4) Server is not running.
5) Incorrect protocol in Connection String
This error occurs just because your database is not connected.
NETBEANS
Go to Services>Database>Java DB>(right click)
After that simply right click on your database and connect database.
Best Solution
To execute the database program
Step 1:
First database server needs to be started
Open a command shell and change to a directory that will hold the database
files(in this following example the database going to stored in
D:\java2019\Database)
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\startNetworkServer“
Wed Mar 13 10:36:36 IST 2019 : Security manager installed using the Basic server security policy.
Wed Mar 13 10:36:37 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527
The default port number is 1527 we can also change the port number by the following
cmd
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\startNetworkServer" -p 1567
Wed Mar 13 10:46:33 IST 2019 : Security manager installed using the Basic server security policy.
Wed Mar 13 10:46:33 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1567
Step2:
compile and execute the java program
Open another command shell and change to a directory that will hold the database files. set the classpath for derbyrun.jar
set classpath=".;C:\Program Files\Java\jdk1.8.0_66\db\lib\derbyrun.jar”
Step3:
Finally the database server needs to be stopped
Open another command shell and change
D:\java2019\Database>"C:\Program Files\Java\jdk1.8.0_60\db\bin\stopNetworkServer"
Wed Mar 13 10:56:04 IST 2019 : Apache Derby Network Server - 10.11.1.2 - (1629631) shutdown
I am facing problem on a centOS server while sending java mails. Getting the following exception.
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25, response: -1
I used the following command from the command prompt and I got the mail as expected.
echo "testing" | mail -s"test subject" shantanu.oa#gmail.com
The relevant entry from maillog looks like this...
Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms
Mar 28 20:13:17 postfix/master[28163]: warning: process /usr/libexec/postfix/smtpd pid 10120 exit status 1
Mar 28 20:13:17 postfix/master[28163]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
Mar 28 20:26:22 postfix/smtpd[11001]: warning: SASL: Connect to private/auth failed: Connection refused
How do I correct the problem?
From the log entry
Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms
I suspect that the problem is on Postfix, of which I'm not an expert. Googling for "fatal: no SASL authentication mechanisms" gives lots of interesting links: maybe have a look here or here.
From the exception it seems like its not able to connect to the host.
Have you tried the telnet stuff?
One more thing to check would be whether the name to IP resolution is taking place properly.If not you can use the IP directly in place of host to see what happens.
does your smtp-server needs authentication?
Seems so, because the cmd call with mail works. In default postfix configuration a local user is allowed to send mails without authentication. And your Java application might not be a registered system user on this maschine.
Try to provide username and password in your code to login to the smtp server.