db = new Mongo().getDB("Customer")
// Command will execute successfully.
db.listCommands()
// Now command will return a connection timeout error.
Actual Result:
Command executes, but when we execute next command it returns error message.
Expected Result:
ADS should have returned error message when we execute first command.
Observation;
When we execute same command in MongoCLI an error message " 2015-11-21T16:47:28.936+0530 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed" is displayed.
This issue is observed both in MongoShell and MongoJS.
MongoShell even change database name in the DB name displayed in tab.
Same is observed in ADS V16 as well,tested against version, Version: 16.0.9-5
|
82 KB
|
76 KB
|
107 KB
|
86 KB
|
41 KB
|
187 KB
@ambikesh: pls debug & provide your analysis as to why this is occurring in ADS.
@Sachin :
I have found following observation during the debugging :
1) In Mongo class it gets undefined object and then it adds by default localhost and port number.
After that is put the localhost and port number into the hostStringBuilder and return as a new mongo instance.
hostStringBuilder.append("127.0.0.1");
put("host", this, hostStringBuilder.toString());
Once local mongo instance is created then db = new Mongo().getDB("Customer") run successfully.
@Sachin :
I have found following observation during the debugging :
1) In Mongo class it gets undefined object and then it adds by default localhost and port number.
After that is put the localhost and port number into the hostStringBuilder and return as a new mongo instance.
hostStringBuilder.append("127.0.0.1");
put("host", this, hostStringBuilder.toString());
Once local mongo instance is created then db = new Mongo().getDB("Customer") run successfully.
@ambikesh: pls debug further. Determine whether the code attempts to make a connection to the host value 127.0.0.1. If it does, why is an error message not displayed/ If it does not, specify the code logic where it is explicitly choosing to not make a connection
@ambikesh: pls debug further. Determine whether the code attempts to make a connection to the host value 127.0.0.1. If it does, why is an error message not displayed/ If it does not, specify the code logic where it is explicitly choosing to not make a connection
Determine whether the code attempts to make a connection to the host value 127.0.0.1. If it does, why is an error message not displayed/ If it does not, specify the code logic where it is explicitly choosing to not make a connection
@Sachin: The Mongo Java Driver library performs lazy socket communication with MongoDB Server. This means that commands such as new Mongo()
or new Mongo().getDB("Customer")
simply creates some wrappers ( com.aquafold.mongoshell.engine.mongorhino.adaptor.Mongo resp. com.aquafold.mongoshell.engine.mongorhino.adaptor.DB instances ) where configuration is set up, but wire communication occurs only when functions like find() or runCommand() etc. are invoked.
I guess that the C++ code implemented for original MongoShell CLI does not perform lazy wire communication but actually creates socket connection when new Mongo()
is invoked.
Determine whether the code attempts to make a connection to the host value 127.0.0.1. If it does, why is an error message not displayed/ If it does not, specify the code logic where it is explicitly choosing to not make a connection
@Sachin: The Mongo Java Driver library performs lazy socket communication with MongoDB Server. This means that commands such as new Mongo()
or new Mongo().getDB("Customer")
simply creates some wrappers ( com.aquafold.mongoshell.engine.mongorhino.adaptor.Mongo resp. com.aquafold.mongoshell.engine.mongorhino.adaptor.DB instances ) where configuration is set up, but wire communication occurs only when functions like find() or runCommand() etc. are invoked.
I guess that the C++ code implemented for original MongoShell CLI does not perform lazy wire communication but actually creates socket connection when new Mongo()
is invoked.
@Emil : When undefined objects comes in Mongo constructor it automatically assign host : localhost ,Port : 27017.After that initMongoConnection() function is called and it creates a connection.It does not check whether localhost is running or not and it automatically a connection.
Please refer attechement : secondconn.png
@Emil : When undefined objects comes in Mongo constructor it automatically assign host : localhost ,Port : 27017.After that initMongoConnection() function is called and it creates a connection.It does not check whether localhost is running or not and it automatically a connection.
Please refer attechement : secondconn.png
That's true. The Mongo Java Driver library performs lazy socket communication. In order to force it to create a new socket connection at a given moment (e.g. during the execution of the Mongo.initMongoConnection() method), the following workaround can be used:
--- a/source/aqua-mongo/src/main/java/com/aquafold/mongoshell/engine/mongorhino/adaptor/Mongo.java +++ b/source/aqua-mongo/src/main/java/com/aquafold/mongoshell/engine/mongorhino/adaptor/Mongo.java @@ -159,6 +161,15 @@ clientOptions); if(options != 0) this.innerMongo.setOptions(options); + // see https://www.aquaclusters.com/app/home/project/public/aquadatastudio/issue/13889 + DBTCPConnector connector = innerMongo.getConnector(); + connector.requestStart(); + try { + connector.requestEnsureConnection(innerMongo.getReadPreference()).ensureOpen(); + } catch (IOException ioe) { + } finally { + connector.requestDone(); + } } if (mongoScope.useMongoShellWriteConcern()) innerMongo.setWriteConcern(WriteConcern.UNACKNOWLEDGED);
By applying this patch, when a new Mongo instance is created (e.g. new Mongo()
) using MongoJS or ADS MongoShell, an exception will be thrown (after a 10 seconds timeout delay) if MongoDB Server is not running on that port.
That's true. The Mongo Java Driver library performs lazy socket communication. In order to force it to create a new socket connection at a given moment (e.g. during the execution of the Mongo.initMongoConnection() method), the following workaround can be used:
--- a/source/aqua-mongo/src/main/java/com/aquafold/mongoshell/engine/mongorhino/adaptor/Mongo.java +++ b/source/aqua-mongo/src/main/java/com/aquafold/mongoshell/engine/mongorhino/adaptor/Mongo.java @@ -159,6 +161,15 @@ clientOptions); if(options != 0) this.innerMongo.setOptions(options); + // see https://www.aquaclusters.com/app/home/project/public/aquadatastudio/issue/13889 + DBTCPConnector connector = innerMongo.getConnector(); + connector.requestStart(); + try { + connector.requestEnsureConnection(innerMongo.getReadPreference()).ensureOpen(); + } catch (IOException ioe) { + } finally { + connector.requestDone(); + } } if (mongoScope.useMongoShellWriteConcern()) innerMongo.setWriteConcern(WriteConcern.UNACKNOWLEDGED);
By applying this patch, when a new Mongo instance is created (e.g. new Mongo()
) using MongoJS or ADS MongoShell, an exception will be thrown (after a 10 seconds timeout delay) if MongoDB Server is not running on that port.
Based upon Emil's explanation here, we keep the behavior as is & no change is required. @ambikesh: if you have checked-in in any code associated w/ this issue, pls rollback. Then, mark issue as "Won't Fix"
Based upon Emil's explanation here, we keep the behavior as is & no change is required. @ambikesh: if you have checked-in in any code associated w/ this issue, pls rollback. Then, mark issue as "Won't Fix"
@Sachin,
I did not check in into the branch.I just sent patch file to Jenny.
@Sachin,
I did not check in into the branch.I just sent patch file to Jenny.
Verified in 17.0.0-rc-46 as per Sachin's comment.
Verified in 17.0.0-rc-46 as per Sachin's comment.
Verified in ADS17.0.0-GA-5
Please refer screenshot: Fixed-17GA5
Info: Timed out error message is displayed only when, on local machine- Mongod is not running on port 27017.
Because the command mentioned in this issue tries to connect to localhost default port mongod connection,
when it fails to connect with registered remote server connection.
Steps:
Connect ADS to Remote Mongod connection.
and execute the command mentioned in issue, it will display timed out error message.
Verified in ADS17.0.0-GA-5
Please refer screenshot: Fixed-17GA5
Info: Timed out error message is displayed only when, on local machine- Mongod is not running on port 27017.
Because the command mentioned in this issue tries to connect to localhost default port mongod connection,
when it fails to connect with registered remote server connection.
Steps:
Connect ADS to Remote Mongod connection.
and execute the command mentioned in issue, it will display timed out error message.
Reopening for following scenario:
The command is working correctly and shows Error message when tried to connect to non existing ip.
Can we shorten the error message.
Current error message displayed is:
Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}].
Expected:
Failed to connect to localhost. Errno: 111 Connection Refused.
Reopening for following scenario:
The command is working correctly and shows Error message when tried to connect to non existing ip.
Can we shorten the error message.
Current error message displayed is:
Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}].
Expected:
Failed to connect to localhost. Errno: 111 Connection Refused.
The original problem reported in description has been solved. Due to the way how errors are internally handled inside MongoDB Java Driver, is not possible to alter the error message and display only the inner part (i.e. root cause and not the timeout exception message).
The original problem reported in description has been solved. Due to the way how errors are internally handled inside MongoDB Java Driver, is not possible to alter the error message and display only the inner part (i.e. root cause and not the timeout exception message).
Verified in ADS-18.0.0-DEVI-88.
Please refer screenshot: verify13889.png
Verified in ADS-18.0.0-DEVI-88.
Please refer screenshot: verify13889.png
Issue #13889 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 18.0.0-devi-83 (mongo-jdbc 2.4.8.2) |
No time estimate |
1 issue link |
is a duplicate of #13987
Issue #13987Mongo JS command "connect" command with wrong IP addr -- display error message |
@ambikesh: pls debug & provide your analysis as to why this is occurring in ADS.