mashingan / anonimongo

Another Nim pure Mongo DB driver
MIT License
43 stars 5 forks source link

IOError from -d:ssl compiler flag #19

Closed C-NERD closed 2 years ago

C-NERD commented 2 years ago

Here is the part of the code that's causing the error

let mongo = newMongo[AsyncSocket](host = host, port = port)
mongo.noSlave()
if not waitFor mongo.connect():

    fatal(fmt"Failed to bind to mongodb on host {host} at port {port}")
    info("Quiting...")
    quit(QuitFailure)

To be specific it's mongo.connect(). It returns

streams.nim(412)         read
asyncfutures.nim(389)    read
utils.nim(40)            sendOpsIter
asyncfutures.nim(389)    read
asyncfutures.nim(389)    read
asyncfutures.nim(389)    read
asyncfutures.nim(389)    read
Error: unhandled exception: cannot read from stream [IOError]

when i compile with the -d:ssl compiler flag, I need the compiler flag because my application uses ssl for sending emails. Is there a way to fix this ?

mashingan commented 2 years ago

Is the mongod server running with option --sslMode requireSSL ?

mashingan commented 2 years ago

Or you can define when initialized Mongo like this let mongo = newMongo[AsyncSocket](host = host, port = port, ssl = false) or let mongo = newMongo[AsyncSocket](MongoUri fmt"mongodb://{host}:{port}/")

C-NERD commented 2 years ago

Or you can define when initialized Mongo like this let mongo = newMongo[AsyncSocket](host = host, port = port, ssl = false) or let mongo = newMongo[AsyncSocket](MongoUri fmt"mongodb://{host}:{port}/")

This works. Thanks 👍 Also if you don't mind what caused the problem in the first place.

mashingan commented 2 years ago

The simple newMongo had issue with when defined(ssl) before, see issue #13 .
Since this is solved, I'm going to close this one. If there's another problem, feel free to open new issue. Thanks