Rishang

Rishang

[error] Mongo.MongoDBConnection (#PID<0.866.0>) disconnected: ** (Mongo.Error) cluster0-shard-00-01.8vwd1.mongodb.net:27017 tcp recv: unknown POSIX error - :closed

Using {:mongodb_driver, “~> 0.9.1”},

Supervisor child spec

%{
        id: Mongo2,
        start:
          {Mongo, :start_link,
           [
             [
               name: :mongo2,
               url: "Remote MONGO DB URL its not local ",
               timeout: 100_000,
               pool_timeout: 100_000,
             ]
           ]}
      }

I am using IMAP to get mails and store the Envelope into Mongo
Even though the application is ideal or mongo is writing suddenly it gives below error

[error] Mongo.MongoDBConnection (#PID<0.866.0>) disconnected: ** (Mongo.Error) cluster0-shard-00-01.8vwd1.mongodb.net:27017 tcp recv: unknown POSIX error - :closed

Any help appreciated

@zookzook

Marked As Solved

zookzook

zookzook

Thanks for the video. The error occurs when you start writing. I think, you need to increase the timeout, when writing to the database:

try this

Mongo.OrderedBulk.write(:mongo, "Mails", 1_000, timeout: 60 * 1_000 * 5)

for 5 minutes.

It is a good idea to turn on the logging:

config :mongodb_driver, log: true

Also Liked

zookzook

zookzook

I created a database using the Atlas service:

{:ok, conn} = Mongo.start_link(url: "mongodb+srv://<secrect>p@cluster0.169dm4y.mongodb.net/myFirstDatabase")

> Mongo.insert_one(conn, "dogs", %{name: "Greta"})
[info] CMD insert "dogs" [documents: [[_id: #BSON.ObjectId<63135a954ae06e5ccaa3e990>, name: "Greta"]]] db=109.9ms (module=Mongo function=do_log/5 line=1800 )

{:ok, %Mongo.InsertOneResult{acknowledged: true, inserted_id: #BSON.ObjectId<63135a954ae06e5ccaa3e990>}}
> Mongo.insert_one(conn, "dogs", %{name: "Tom"})
[info] CMD insert "dogs" [documents: [[_id: #BSON.ObjectId<63135a9a4ae06e5cca171679>, name: "Tom"]]] db=32.7ms (module=Mongo function=do_log/5 line=1800 )

{:ok, %Mongo.InsertOneResult{acknowledged: true, inserted_id: #BSON.ObjectId<63135a9a4ae06e5cca171679>}}
> Mongo.find(conn, "dogs", %{}) |> Enum.to_list()
[info] CMD find "dogs" [] db=23.2ms (module=Mongo function=do_log/5 line=1800 )

[
  %{"_id" => #BSON.ObjectId<63135a954ae06e5ccaa3e990>, "name" => "Greta"},
  %{"_id" => #BSON.ObjectId<63135a9a4ae06e5cca171679>, "name" => "Tom"}
]

Everything works as expected. Maybe your IP address is not whitelisted.

Rishang

Rishang

Hi @zookzook apologies for the delay was on leave for a week, Yeah the problem is solved.

Thank you very much. our production server is running fine since then.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement