Skip to content

Disable persistent connection #756

@dercoder

Description

@dercoder

Hello,

i am creating some threads using Parallel but after close this threads, the connections are still open and i have no idea how to close them.

After a while a "Too many open files" exception will be thrown. I know i can increase them but that will not solve the problem.

lsof -p 22489

php     22489 ec2-user   11u  IPv4 299183318       0t0    TCP localhost:41484->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   12u  IPv4 299187424       0t0    TCP localhost:43650->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   13u  IPv4 299187500       0t0    TCP localhost:43834->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   14u  IPv4 299182643       0t0    TCP localhost:41910->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   15u  IPv4 299189548       0t0    TCP localhost:45064->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   16u  IPv4 299186431       0t0    TCP localhost:44190->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   17u  IPv4 299187521       0t0    TCP localhost:43986->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   18u  IPv4 299183598       0t0    TCP localhost:41918->localhost:27017 (ESTABLISHED)
php     22489 ec2-user   19u  IPv4 299187621       0t0    TCP localhost:44378->localhost:27017 (ESTABLISHED)
....

So how can I disable the persistent mode like on MySQL?
or how can i close the connection?

I am using

PHP 7.3.19 (cli) (built: Jun 13 2020 12:55:28) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
MongoDB support => enabled
MongoDB extension version => 1.7.4
MongoDB extension stability => stable
libbson bundled version => 1.16.2
libmongoc bundled version => 1.16.2
libmongoc SSL => enabled
libmongoc SSL library => OpenSSL
libmongoc crypto => enabled
libmongoc crypto library => libcrypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc ICU => disabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled
libmongocrypt bundled version => 1.0.3
libmongocrypt crypto => enabled
libmongocrypt crypto library => libcrypto

Directive => Local Value => Master Value
mongodb.debug => no value => no value

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracked-in-jiraTicket filed in Mongo's Jira system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions