The parameter: client, in function mongoc_client_get_uri, cannot be NULL

I’m trying to set up a phpfpm, nginx and mongodb stack in docker. I have a strange problem, which only occurs when capturing the request with xdebug.
When the request is not captured, the result is as expected, if I try to debug a request, I get this error in the php container:

“The parameter: client, in function mongoc_client_get_uri, cannot be NULL
WARNING: [pool www] child 219 exited on signal 6 (SIGABRT) after 171.996764 seconds from start”

This error occurs when trying to create the mongo Manager in vendor/mongodb/mongodb/src/Client.php with this code:

$this->manager = new Manager($uri, $uriOptions, $driverOptions);

The uri passed is correct:

$uri=mongodb://user:pass@mongodb:27017/database

Where user, pass and database have the appropriate values.
My mongo php config:

php -i | grep -i "mongo"
mongodb
MongoDB support => enabled
MongoDB extension version => 1.19.3
MongoDB extension stability => stable
libmongoc bundled version => 1.27.2
libmongoc SSL => enabled
libmongoc SSL library => OpenSSL
libmongoc crypto => enabled
libmongoc crypto library => libcrypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc SRV => enabled
libmongoc compression => enabled
libmongoc compression snappy => enabled
libmongoc compression zlib => enabled
libmongoc compression zstd => enabled
libmongocrypt bundled version => 1.10.0
libmongocrypt crypto => enabled
libmongocrypt crypto library => libcrypto
mongodb.debug => stderr => stderr

My php version:

php -v
PHP 8.2.20 (cli) (built: Jul  2 2024 03:47:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.20, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.20, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

Example code:

<?php
require '../vendor/autoload.php';

$uri = 'mongodb://user:pass@mongodb:27017/database';
try {
    $client = new MongoDBClient($uri, ['readPreference' => 'primaryPreferred']);
    echo "Connection successful!";
} catch (Exception $e) {
    echo 'Error connecting to MongoDB: ' . $e->getMessage();
}

Phpfpm log when request is not captured and successful:

2024-07-22 13:54:54 NOTICE: PHP message: Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port).
2024-07-22 13:54:54 [2024-07-22T11:54:54.373389+00:00]     PHONGO: DEBUG   > Connection string: 'mongodb://user:pass@mongodb:27017/database'
2024-07-22 13:54:54 [2024-07-22T11:54:54.373647+00:00]     PHONGO: DEBUG   > Creating Manager, phongo-1.19.3[stable] - mongoc-1.27.2(bundled), libbson-1.27.2(bundled), php-8.2.20
2024-07-22 13:54:54 [2024-07-22T11:54:54.373702+00:00]     PHONGO: DEBUG   > Setting driver handshake data: { name: 'ext-mongodb:PHP / PHPLIB ', version: '1.19.3 / 1.19.1 ', platform: 'PHP 8.2.20 ' }
2024-07-22 13:54:54 [2024-07-22T11:54:54.373765+00:00]     client: TRACE   > ENTRY: mongoc_client_new_from_uri_with_error():1001
2024-07-22 13:54:54 [2024-07-22T11:54:54.373886+00:00]     mongoc: TRACE   > ENTRY: mongoc_topology_description_init():79
2024-07-22 13:54:54 [2024-07-22T11:54:54.373984+00:00]     mongoc: TRACE   >  EXIT: mongoc_topology_description_init():97
2024-07-22 13:54:54 [2024-07-22T11:54:54.374060+00:00]     mongoc: TRACE   > ENTRY: mongoc_server_description_init():121
2024-07-22 13:54:54 172.18.0.4 -  22/Jul/2024:13:54:54 +0200 "GET /test.php" 200
2024-07-22 13:54:54 [2024-07-22T11:54:54.374125+00:00]     mongoc: TRACE   >  EXIT: mongoc_server_description_init():149
2024-07-22 13:54:54 [2024-07-22T11:54:54.374172+00:00]    cluster: TRACE   > ENTRY: mongoc_cluster_init():2505
2024-07-22 13:54:54 [2024-07-22T11:54:54.374197+00:00]    cluster: TRACE   >  EXIT: mongoc_cluster_init():2528
2024-07-22 13:54:54 [2024-07-22T11:54:54.374202+00:00]     client: TRACE   >  EXIT: mongoc_client_new_from_uri_with_error():1030
2024-07-22 13:54:54 [2024-07-22T11:54:54.374226+00:00]     PHONGO: DEBUG   > Created client with hash: a:4:{s:3:"pid";i:223;s:3:"uri";s:56:"mongodb://user:pass@mongodb:27017/database";s:7:"options";a:1:{s:14:"readPreference";s:16:"primaryPreferred";}s:13:"driverOptions";a:1:{s:6:"driver";a:2:{s:4:"name";s:6:"PHPLIB";s:7:"version";s:6:"1.19.1";}}}
2024-07-22 13:54:54 [2024-07-22T11:54:54.374264+00:00]     PHONGO: DEBUG   > Stored persistent client with hash: a:4:{s:3:"pid";i:223;s:3:"uri";s:56:"mongodb://user:pass@mongodb:27017/database";s:7:"options";a:1:{s:14:"readPreference";s:16:"primaryPreferred";}s:13:"driverOptions";a:1:{s:6:"driver";a:2:{s:4:"name";s:6:"PHPLIB";s:7:"version";s:6:"1.19.1";}}}
2024-07-22 13:54:54 [2024-07-22T11:54:54.374396+00:00]     PHONGO: DEBUG   > Not destroying persistent client for Manager

Phpfpm log when request is captured and fails:

2024-07-22 13:59:49 The parameter: client, in function mongoc_client_get_uri, cannot be NULL
2024-07-22 13:59:49 [22-Jul-2024 13:59:49] WARNING: [pool www] child 227 exited on signal 6 (SIGABRT) after 1708.727192 seconds from start
2024-07-22 13:59:49 [22-Jul-2024 13:59:49] NOTICE: [pool www] child 229 started

Without capturing the request the result is “Connection successful!”. Capturing the request gives the aforementioned error.
Any idea what’s going on or how to investigate further?

I have also activated the debug of the MongoDB Extension php extension but I cannot see why this error occurs. I have tried different versions of the mongoc driver, the php extension and the mongo database version and verified that they are compatible.

Thank you.

New contributor

Pablo Bcn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật