The problem I have; I get some timeout :
Caused by: org.openqa.grid.common.exception.GridException: Session [88131a70-87d7-4cf7-b7a5-f01de85f6012] was terminated due to TIMEOUT.
For those tests, the tests start and are very long. That's ok that they are long because the test waits for a third party to receive a response. So, I don't want to have the grid to terminate the test.
I have a selenium Grid, with 1 hub and 2 nodes.
Nodes configuration are as follow :
"port": 5554,
"hubPort": 4444,
"hubHost": "xxx.yyy.zzzz",
"nodePolling": 5000,
"registerCycle": 1800000,
"register": true,
"cleanUpCycle": 5000,
"timeout": 12000,
"browserTimeout": 12000,
"nodeStatusCheckTimeout": 12000,
"maxSession": 4
For the Hub part, no config file is set.
I'm currently running selenium server 2.53.0.
As I can see, my timeout, browserTimeout and nodeStatusCheckTimeout are more than enough to wait for the completion of the test before the connection is dropped.
The problem occurs about 5 minutes after the test is launched.
Selenium grid serves all your selenium requests, as a result you'll have to increase the -jettyMaxThreads. The default is 200 (selenium v3.11). You might run more load than what your jetty engine can handle.
Using : Ubuntu 16.04.3
I'm connecting to a replica set through mongodb java driver v3.4.3 (or 3.5.0) . I may create the MongoClient by providing the IPs , or the hostnames I have provided in the /etc/hosts file as such :
new MongoClient(
Arrays.asList(
new ServerAddress("X.X.Y.A",27017),
new ServerAddress("X.X.Y.B",27017),
new ServerAddress("X.X.Y.C",27017))
);
or
new MongoClient(new MongoClientURI("mongodb://X.X.Y.A:27017/?replicaSet=my-rs"));
or
//myserver1 on /etc/hosts as X.X.Y.A myserver1
new MongoClient(new MongoClientURI("mongodb://myserver1:27017/?replicaSet=my-rs"));
in both cases , mongodb is trying to monitor the replica sets as "mongodb1" , "mongodb2" and "mongodb3" and keeps throwing the INFO Log and prevents the execution :
Oct 18, 2017 9:12:13 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server mongodb3:27017
com.mongodb.MongoSocketException: mongodb1
at com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:188)
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57)
at com.mongodb.connection.SocketStream.open(SocketStream.java:58)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: mongodb1
at java.net.InetAddress.getAllByName0(InetAddress.java:1280)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at java.net.InetAddress.getByName(InetAddress.java:1076)
at com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:186)
... 5 more
Throwing the similar exceptions for "mongodb2" and "mongodb3" .
But when i add the mongodb1 etc rows on /etc/hosts file , everything works as :
X.X.Y.A mongodb1
X.X.Y.B mongodb2
X.X.Y.C mongodb3
This leads me to think that mongo driver is hardcodedly monitoring the N members of the replicaset as "mongodbN:port". Is this a bug on mongodb java driver or just incredibly useless way of doing it ?
Problem: MongoDB writes fail with the error -
Timed out after 30000 ms while waiting for a server that matches
PrimaryServerSelector. Client view of cluster state is
{type=REPLICA_SET, servers=[{address=intdb01:27017,
type=REPLICA_SET_SECONDARY, roundTripTime=0.7 ms, state=CONNECTED}]
This happens when the primary has switched from intdb01 to intdb02.
Looks like the client driver is still looking for intdb01
to be primary node.
Our Setup
We have 3 mongoDb nodes in a replicaSet called rs0.
When we connect to it using Java, we give all 3 servers in the connection string as follows:
mongodb://intdb01:27017,intdb02:27017,intdb03:27017/?replicaSet=rs0
db.version --> 3.0.4
Java Driver Version: mongodb-driver-3.0.4.jar, mongodb-driver-core-3.0.4.jar
Client Connection code:
if( mongoClient == null) {
MongoClientURI mcu = new MongoClientURI(mongoConnect);
mongoClient = new MongoClient(mcu);
}
mongoConnect contains the connection string shown above.
Mongo Replicaset Status Info
> rs.status()
{
"set" : "rs0",
"date" : ISODate("2016-07-19T21:14:03.001Z"),
"myState" : 1,
"members" : [{
"_id" : 0,
"name" : "intdb01",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 439786,
"optime" : Timestamp(1468521291, 5),
"optimeDate" : ISODate("2016-07-14T18:34:51Z"),
"lastHeartbeat" : ISODate("2016-07-19T21:14:01.877Z"),
"lastHeartbeatRecv" : ISODate("2016-07-19T21:14:01.611Z"),
"pingMs" : 0,
"configVersion" : 4
},
{
"_id" : 1,
"name" : "intdb02:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 2948844,
"optime" : Timestamp(1468521291, 5),
"optimeDate" : ISODate("2016-07-14T18:34:51Z"),
"electionTime" : Timestamp(1468523057, 1),
"electionDate" : ISODate("2016-07-14T19:04:17Z"),
"configVersion" : 4,
"self" : true
},
{
"_id" : 2,
"name" : "intdb03:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 439779,
"optime" : Timestamp(1468521291, 5),
"optimeDate" : ISODate("2016-07-14T18:34:51Z"),
"lastHeartbeat" : ISODate("2016-07-19T21:14:01.294Z"),
"lastHeartbeatRecv" : ISODate("2016-07-19T21:14:01.294Z"),
"pingMs" : 0,
"configVersion" : 4
}
],
"ok" : 1
}
I have checked and rechecked the code/config with the documentation but cannot find what is amiss.
We can simulate this by stepping down the primary.
The Secondary takes over but the app writes start failing. :-(
Any pointers/tips much appreciated!
Adding Stack trace-
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=intdb01:27017, type=REPLICA_SET_SECONDARY, roundTripTime=0.7 ms, state=CONNECTED}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:175)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:141)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:72)
at com.mongodb.Mongo.execute(Mongo.java:747)
at com.mongodb.Mongo$2.execute(Mongo.java:730)
at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:482)
at com.mongodb.MongoCollectionImpl.update(MongoCollectionImpl.java:474)
at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:325)
at com.grid.core.persistence.mongodb.dao.GridEventDao.save(GridEventDao.java:69)
... 6 more
2016-07-19 17:05:01,882 [pool-2-thread-2] INFO org.mongodb.driver.cluster - No server chosen by PrimaryServerSelector from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=SINGLE, all=[ServerDescription{address=intdb01:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 4]}, minWireVersion=0, maxWireVersion=3, electionId=null, maxDocumentSize=16777216, roundTripTimeNanos=724681, setName='rs0', canonicalAddress=intdb01:27017, hosts=[intdb01:27017, intdb02:27017], passives=[intdb03:27017], arbiters=[], primary='intdb02:27017', tagSet=TagSet{[]}}]}. Waiting for 30000 ms before timing out
I am trying to figure out if it is a coding error or configuration.
The last info Message in the stack trace, says connectionMode is SINGLE. Have a suspicion that it is causing this issue but I cannot find any info about it in the developer documentation site.
All of the server addresses should appear in the error message. For example, try this with 3 arbitrary hostnames what won't resolve:
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=xxx:27117, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xxx}, caused by {java.net.UnknownHostException: xxx}}, {address=xxx:27118, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xxx}, caused by {java.net.UnknownHostException: xxx}}, {address=xxx:27119, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xxx}, caused by {java.net.UnknownHostException: xxx}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:175)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:106)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:58)
at com.mongodb.Mongo.execute(Mongo.java:747)
at com.mongodb.Mongo$2.execute(Mongo.java:730)
at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:327)
at com.mongodb.DBCollection.insert(DBCollection.java:323)
at com.mongodb.DBCollection.insert(DBCollection.java:314)
at com.mongodb.DBCollection.insert(DBCollection.java:284)
at com.mongodb.DBCollection.insert(DBCollection.java:250)
at com.mongodb.DBCollection.insert(DBCollection.java:187)
at InsertTest2.main(InsertTest2.java:26)
Notice how all 3 server addresses appear. I would suggest that you create a simple test program like this and verify, then work backwards from there. Also verify that the hostnames resolve correctly, you might also try IP addresses.
I have a selenium grid that uses the following config:
{
"port": 4444,
"newSessionWaitTimeout": 2000
}
and 2 nodes that use this config:
{
"capabilities": [{
"browserName": "chrome",
"platform": "LINUX",
"maxInstances": 8
}],
"configuration": {
"nodeTimeout": 120,
"port": 5555,
"hubPort": 4444,
"hubHost": "hubhost",
"nodePolling": 2000,
"registerCycle": 10000,
"register": true,
"cleanUpCycle": 2000,
"timeout": -1,
"browserTimeout": -1,
"maxSession": 8
}
}
I wrote a piece of Java-Code that opens a connection via the RemoteWebDriver-Class. The code does several calls on the driver and afterward suspends for unknown time (30s - 1h). I don't want to close the session, because on wake, the process needs to react really fast.
With the timeout set to -1 everything works. The process will stay connected to the session (and the browser) for unlimited time. Unfortunately, the process is killed at random, when an automatic service decides to.
The node recognizes that the client shuts down:
selenium deleted due to client timeout
But the sessions aren't cleaned up! The unlimited timeout keeps them alive and the grid won't free them for further use.
How can I solve this problem with the selenium config?
Building a process-shutdown-hook that calls "driver.quit()" to free the session, is not an option.
Thanks for any help!
Did you notice the "cleanUpCycle": 2000 setting in the config ?
It means that the Hub will cleanup itself in 2000 milliseconds !
I have a java/dropwizard application using elasticsearch (running version 1.3.2 but I've also tested with 1.4.0)
For local development/testing I use elasticsearch in local mode, starting it with the following commands:
Node node = nodeBuilder().local(true).node();
Client client = node.client();
According the documentation (http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html, section on Node Client) this should be sufficient, but I'm not able to run any queries. Checking the health status I get the following result:
{
"cluster_name" : "elasticsearch",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 10
}
I assume the problem is that I have no active shards. Do anyone know how activate shards for this kind of setup?