[JAVA-2952] Start session failed Created: 30/Aug/18  Updated: 27/Oct/23  Resolved: 31/Aug/18

Status: Closed
Project: Java Driver
Component/s: Session Management
Affects Version/s: 3.8.1
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Jie Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows


Attachments: JPEG File Untitled.jpg    
Issue Links:
Related
is related to JAVA-2956 Add Javadoc to startSession methods i... Closed

 Description   

I have a mongodb server 4.0.1, start with below script. It's a single server.

mongod --auth --dbpath "C:\Program Files\MongoDB\Server\4.0\data" --bind_ip 127.0.0.1 --wiredTigerCacheSizeGB 8

When create session in Java, it failed.

// java code
MongoClient client = new MongoClient("127.0.0.1" , 27017);
ClientSession session = client.startSession();
 
 
// output
INFO: Monitor thread successfully connected to server with description ServerDescription{address=127.0.0.1:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=2414624}
Exception in thread "main" com.mongodb.MongoClientException: Sessions are not supported by the MongoDB cluster to which this client is connected



 Comments   
Comment by Jeffrey Yemin [ 31/Aug/18 ]

Linked to JAVA-2952, which requests documentation updates.

Comment by Jeffrey Yemin [ 31/Aug/18 ]

esestt

ClientSession#startSession is not the same as the startSession command. It applies different rules for whether a session is allowed. See the sessions spec for the details.

Comment by Jie [ 31/Aug/18 ]

Jeff,

Thanks for your reply. 

I saw the documentation. but I can start session with Robo3T shell.

command:

db.runCommand( { startSession: 1 } )

output:

{
"id" :

{ "id" : UUID("5cc08089-f8dd-44cb-aa0a-71f60f8d8e89") }

,
"timeoutMinutes" : 30,
"ok" : 1.0
}

 

BTW, the site prompt error "JIRA could not attach the file as there was a missing token", when I tried to update a screenshot picture.

Comment by Jeffrey Yemin [ 30/Aug/18 ]

Please create a replica set and try again, as startSession doesn't work with a standalone mongod server.   See https://docs.mongodb.com/manual/reference/server-sessions/#overview for details.

This should be included in the Javadoc though, so I may re-purpose this ticket as a request for better documentation.

Comment by Jie [ 30/Aug/18 ]

I tried startSession with shell. It's ok. Obviously, it's a driver issue.

Generated at Thu Feb 08 08:58:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.