How to fix the SSLHandshakeFailed in ReactiveMongo to connect MongoDB atlas?
how can I fix the below exception
Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections.
My code is
object GetStarted {
val mongoUri = "mongodb://reddy:<password>@cluster0-shard-00-00-4u9oj.mongodb.net:27017,cluster0-shard-00-01-4u9oj.mongodb.net:27017,cluster0-shard-00-02-4u9oj.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true"
import ExecutionContext.Implicits.global // use any appropriate context
val driver = MongoDriver()
val parsedUri = MongoConnection.parseURI(mongoUri)
val connection = parsedUri.map(driver.connection(_))
val futureConnection = Future.fromTry(connection)
def db1: Future[DefaultDB] = futureConnection.flatMap(_.database("agshift"))
def personCollection: Future[BSONCollection] = db1.map(_.collection("agshift_version"))
println(" futureConnection " + futureConnection)
implicit def personWriter: BSONDocumentWriter[Person] = Macros.writer[Person]
import scala.concurrent.duration._
def createPerson(): Either[Future[Unit], String] = {
try {
Left(personCollection.flatMap(_.insert(BSONDocument("1c" -> "1x")).map(_ => {}))) // use personWriter)
} catch {
case e: Exception =>
println(" createPerson ======== " + e.toString)
Right(e.toString)
}
}
val test2 = findCount().onComplete {
case Failure(e) => println(" test2 Exception " + e.toString)
case Success(writeResult) => {
println(s"successfully inserted document: $writeResult")
}
}
def findCount(): Future[Either[Int, String]] = {
try {
val resp = personCollection.flatMap(_.count(Some(BSONDocument("agsky" -> "1.0.112"))).map(i => i))
println(" test :::: " + Await.result(resp, 40 seconds))
Future(Left(Await.result(resp, 40 seconds))) // use personWriter))
} catch {
case e: Exception =>
println(" findPerson ======== " + e.toString)
Future(Right(e.toString))
}
}
implicit def personReader: BSONDocumentReader[Person] = Macros.reader[Person]
case class Person(firstName: String, lastName: String, age: Int)
}
I have used above code to connect MongoDB atlas am getting the SSLHandshakeFailed. How can I handle this?
scala reactivemongo
add a comment |
how can I fix the below exception
Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections.
My code is
object GetStarted {
val mongoUri = "mongodb://reddy:<password>@cluster0-shard-00-00-4u9oj.mongodb.net:27017,cluster0-shard-00-01-4u9oj.mongodb.net:27017,cluster0-shard-00-02-4u9oj.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true"
import ExecutionContext.Implicits.global // use any appropriate context
val driver = MongoDriver()
val parsedUri = MongoConnection.parseURI(mongoUri)
val connection = parsedUri.map(driver.connection(_))
val futureConnection = Future.fromTry(connection)
def db1: Future[DefaultDB] = futureConnection.flatMap(_.database("agshift"))
def personCollection: Future[BSONCollection] = db1.map(_.collection("agshift_version"))
println(" futureConnection " + futureConnection)
implicit def personWriter: BSONDocumentWriter[Person] = Macros.writer[Person]
import scala.concurrent.duration._
def createPerson(): Either[Future[Unit], String] = {
try {
Left(personCollection.flatMap(_.insert(BSONDocument("1c" -> "1x")).map(_ => {}))) // use personWriter)
} catch {
case e: Exception =>
println(" createPerson ======== " + e.toString)
Right(e.toString)
}
}
val test2 = findCount().onComplete {
case Failure(e) => println(" test2 Exception " + e.toString)
case Success(writeResult) => {
println(s"successfully inserted document: $writeResult")
}
}
def findCount(): Future[Either[Int, String]] = {
try {
val resp = personCollection.flatMap(_.count(Some(BSONDocument("agsky" -> "1.0.112"))).map(i => i))
println(" test :::: " + Await.result(resp, 40 seconds))
Future(Left(Await.result(resp, 40 seconds))) // use personWriter))
} catch {
case e: Exception =>
println(" findPerson ======== " + e.toString)
Future(Right(e.toString))
}
}
implicit def personReader: BSONDocumentReader[Person] = Macros.reader[Person]
case class Person(firstName: String, lastName: String, age: Int)
}
I have used above code to connect MongoDB atlas am getting the SSLHandshakeFailed. How can I handle this?
scala reactivemongo
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to aval
(asdb1
).
– cchantep
Nov 22 '18 at 8:26
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47
add a comment |
how can I fix the below exception
Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections.
My code is
object GetStarted {
val mongoUri = "mongodb://reddy:<password>@cluster0-shard-00-00-4u9oj.mongodb.net:27017,cluster0-shard-00-01-4u9oj.mongodb.net:27017,cluster0-shard-00-02-4u9oj.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true"
import ExecutionContext.Implicits.global // use any appropriate context
val driver = MongoDriver()
val parsedUri = MongoConnection.parseURI(mongoUri)
val connection = parsedUri.map(driver.connection(_))
val futureConnection = Future.fromTry(connection)
def db1: Future[DefaultDB] = futureConnection.flatMap(_.database("agshift"))
def personCollection: Future[BSONCollection] = db1.map(_.collection("agshift_version"))
println(" futureConnection " + futureConnection)
implicit def personWriter: BSONDocumentWriter[Person] = Macros.writer[Person]
import scala.concurrent.duration._
def createPerson(): Either[Future[Unit], String] = {
try {
Left(personCollection.flatMap(_.insert(BSONDocument("1c" -> "1x")).map(_ => {}))) // use personWriter)
} catch {
case e: Exception =>
println(" createPerson ======== " + e.toString)
Right(e.toString)
}
}
val test2 = findCount().onComplete {
case Failure(e) => println(" test2 Exception " + e.toString)
case Success(writeResult) => {
println(s"successfully inserted document: $writeResult")
}
}
def findCount(): Future[Either[Int, String]] = {
try {
val resp = personCollection.flatMap(_.count(Some(BSONDocument("agsky" -> "1.0.112"))).map(i => i))
println(" test :::: " + Await.result(resp, 40 seconds))
Future(Left(Await.result(resp, 40 seconds))) // use personWriter))
} catch {
case e: Exception =>
println(" findPerson ======== " + e.toString)
Future(Right(e.toString))
}
}
implicit def personReader: BSONDocumentReader[Person] = Macros.reader[Person]
case class Person(firstName: String, lastName: String, age: Int)
}
I have used above code to connect MongoDB atlas am getting the SSLHandshakeFailed. How can I handle this?
scala reactivemongo
how can I fix the below exception
Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections.
My code is
object GetStarted {
val mongoUri = "mongodb://reddy:<password>@cluster0-shard-00-00-4u9oj.mongodb.net:27017,cluster0-shard-00-01-4u9oj.mongodb.net:27017,cluster0-shard-00-02-4u9oj.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true"
import ExecutionContext.Implicits.global // use any appropriate context
val driver = MongoDriver()
val parsedUri = MongoConnection.parseURI(mongoUri)
val connection = parsedUri.map(driver.connection(_))
val futureConnection = Future.fromTry(connection)
def db1: Future[DefaultDB] = futureConnection.flatMap(_.database("agshift"))
def personCollection: Future[BSONCollection] = db1.map(_.collection("agshift_version"))
println(" futureConnection " + futureConnection)
implicit def personWriter: BSONDocumentWriter[Person] = Macros.writer[Person]
import scala.concurrent.duration._
def createPerson(): Either[Future[Unit], String] = {
try {
Left(personCollection.flatMap(_.insert(BSONDocument("1c" -> "1x")).map(_ => {}))) // use personWriter)
} catch {
case e: Exception =>
println(" createPerson ======== " + e.toString)
Right(e.toString)
}
}
val test2 = findCount().onComplete {
case Failure(e) => println(" test2 Exception " + e.toString)
case Success(writeResult) => {
println(s"successfully inserted document: $writeResult")
}
}
def findCount(): Future[Either[Int, String]] = {
try {
val resp = personCollection.flatMap(_.count(Some(BSONDocument("agsky" -> "1.0.112"))).map(i => i))
println(" test :::: " + Await.result(resp, 40 seconds))
Future(Left(Await.result(resp, 40 seconds))) // use personWriter))
} catch {
case e: Exception =>
println(" findPerson ======== " + e.toString)
Future(Right(e.toString))
}
}
implicit def personReader: BSONDocumentReader[Person] = Macros.reader[Person]
case class Person(firstName: String, lastName: String, age: Int)
}
I have used above code to connect MongoDB atlas am getting the SSLHandshakeFailed. How can I handle this?
scala reactivemongo
scala reactivemongo
edited Nov 23 '18 at 6:09
Sekhar
asked Nov 22 '18 at 4:55
SekharSekhar
518
518
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to aval
(asdb1
).
– cchantep
Nov 22 '18 at 8:26
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47
add a comment |
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to aval
(asdb1
).
– cchantep
Nov 22 '18 at 8:26
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to a
val
(as db1
).– cchantep
Nov 22 '18 at 8:26
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to a
val
(as db1
).– cchantep
Nov 22 '18 at 8:26
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424122%2fhow-to-fix-the-sslhandshakefailed-in-reactivemongo-to-connect-mongodb-atlas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424122%2fhow-to-fix-the-sslhandshakefailed-in-reactivemongo-to-connect-mongodb-atlas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The message is quite explicit: have to check the connection setup, and eventually enable logging to gather traces about what happens. Note: As indicated in the documentation, the DB resolution should never be assigned to a
val
(asdb1
).– cchantep
Nov 22 '18 at 8:26
@cchantep I have updated my code can you please check it now
– Sekhar
Nov 23 '18 at 6:09
Which version OF driver?
– cchantep
Nov 30 '18 at 6:47