@@ -814,6 +814,7 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
814
814
const bson_t * options ;
815
815
bson_iter_t iter ;
816
816
struct timeval * timeoutp = NULL ;
817
+ char * uniqid ;
817
818
char * errmsg = NULL ;
818
819
int errcode ;
819
820
char * dsn ;
@@ -851,12 +852,23 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
851
852
timeout .tv_sec = connecttimeoutms / 1000 ;
852
853
timeout .tv_usec = (connecttimeoutms % 1000 ) * 1000 ;
853
854
854
- mongoc_log (MONGOC_LOG_LEVEL_DEBUG , MONGOC_LOG_DOMAIN , "Connecting to '%s' (%ld.%06ldms timeout)" , dsn , timeout .tv_sec , timeout .tv_usec );
855
855
timeoutp = & timeout ;
856
856
}
857
857
858
- stream = php_stream_xport_create (dsn , dsn_len , 0 , STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT , (char * )"persistent id" , timeoutp , (php_stream_context * )user_data , & errmsg , & errcode );
858
+ spprintf (& uniqid , 0 , "mongodb://%s:%s@%s:%d/%s?authMechanism=%s&authMechanism=%s" ,
859
+ mongoc_uri_get_username (uri ),
860
+ mongoc_uri_get_password (uri ),
861
+ host -> host ,
862
+ host -> port ,
863
+ mongoc_uri_get_database (uri ),
864
+ mongoc_uri_get_auth_mechanism (uri ),
865
+ mongoc_uri_get_auth_source (uri )
866
+ );
859
867
868
+ mongoc_log (MONGOC_LOG_LEVEL_DEBUG , MONGOC_LOG_DOMAIN , "Connecting to '%s'" , uniqid );
869
+ stream = php_stream_xport_create (dsn , dsn_len , 0 , STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT , uniqid , timeoutp , (php_stream_context * )user_data , & errmsg , & errcode );
870
+
871
+ efree (uniqid );
860
872
if (!stream ) {
861
873
bson_set_error (error , MONGOC_ERROR_STREAM , MONGOC_ERROR_STREAM_CONNECT , "Failed connecting to '%s:%d': %s" , host -> host , host -> port , errmsg );
862
874
efree (dsn );
0 commit comments