AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

연결 옵션

이 섹션에서는 .NET/C# 드라이버에서 사용할 수 있는 MongoDB 연결 및 인증 옵션에 대해 설명합니다. 연결 URI 또는 MongoClientSettings 객체를 사용하여 연결을 구성할 수 있습니다.

연결 URI를 MongoClient 생성자에 전달하는 경우 문자열에 연결 옵션을 <name>=<value> 쌍으로 포함할 수 있습니다. 다음 예시에서 연결 URI에는 값이 60000connectTimeoutMS 옵션과 값이 truetls 옵션이 포함되어 있습니다.

using MongoDB.Driver;
// Sets the connection URI
const string connectionUri = "mongodb+srv://sample.host:27017/?connectTimeoutMS=60000&tls=true";
// Creates a new client and connects to the server
var client = new MongoClient(connectionUri);

MongoClientSettings 객체를 사용하여 연결 URI가 아닌 코드에서 연결 설정을 구성할 수 있습니다. 이러한 방식으로 연결을 구성하면 런타임에 설정을 더 쉽게 변경할 수 있고, 컴파일 중에 오류를 포착하는 데 도움이 되며, 연결 URI보다 더 많은 구성 옵션을 제공할 수 있습니다.

MongoClientSettings 객체를 사용하려면 클래스의 인스턴스를 만들고 속성을 설정한 다음 MongoClient 생성자에 인수로 전달하세요.

//const string connectionUri = "mongodb+srv://sample.host:27017/?connectTimeoutMS=60000&tls=true";
// Creates a MongoClientSettings object
var settings = new MongoClientSettings()
{
Scheme = ConnectionStringScheme.MongoDBPlusSrv,
Server = new MongoServerAddress("sample.host", 27017),
ConnectTimeout = new TimeSpan(0, 0, 60),
UseTls = true
};
// Creates a new client and connects to the server
var client = new MongoClient(settings);

다음 표에는 MongoClientSettings 클래스에서 사용할 수 있는 각 연결 옵션과 가능한 경우 연결 문자열에서 동일한 결과를 얻는 방법이 나열되어 있습니다. MongoClientSettings 속성이 연결 문자열에서 둘 이상의 옵션에 매핑되는 경우 연결 URI 예시에는 모든 관련 옵션이 표시됩니다.

참고

특정 기간 동안 쿼리 매개변수를 사용하는 경우 값은 밀리초 단위여야 합니다. 예를 들어 60초를 지정하려면 60000 값을 사용합니다. 해당 시간 동안 MongoClientSettings 객체를 사용하는 경우 적절한 TimeSpan 값을 사용합니다.

MongoClientSettings 속성
설명

AllowInsecureTls

TLS 제한 조건을 최대한 완화할지 여부를 지정합니다. 이에는 유효하지 않은 인증서 또는 호스트 이름 불일치가 포함될 수 있습니다.


이 속성이 으로 설정되고 true 가 로 SslSettings.CheckCertificateRevocation
false설정되면 .NET/C# 드라이버에서 예외가 발생합니다.

데이터 유형: boolean
기본값: false
연결 URI 예시: tlsInsecure=true

애플리케이션 이름

연결 핸드신크의 일부로 드라이버가 클라이언트 메타데이터에서 서버에 전달하는 앱 이름입니다.
연결이 설정되면 서버가 MongoDB 로그에 이 값을 한 번 인쇄합니다.
이 값은 느린 쿼리 로그
및 프로필 컬렉션에도 기록됩니다.

데이터 유형: string
기본값: null
연결 URI 예시: appName=yourApp

자동 암호화 옵션

Settings for automatic client-side encryption.

Data Type: AutoEncryptionOptions
Default: null
Connection URI Example: N/A

클러스터 구성자

Low-level configuration options for sockets, TLS, cluster, and others.

Data Type: Action<ClusterBuilder>
Default: null
Connection URI Example: N/A

압축기

The preferred compression types, in order, for wire-protocol messages sent to
or received from the server. The driver uses the first of these compression types
that the server supports.

Data Type: CompressorConfiguration
Default: null
Connection URI Example: compressors=snappy,zstd

ConnectTimeout

시간이 초과하기 전에 드라이버가 서버에 단일 TCP 소켓 연결을 설정하려고 시도하는 시간의 길이입니다.


데이터 유형: TimeSpan
기본값: 30 초
연결 URI 예시: connectTimeoutMS=0

자격 증명

Settings for how the driver authenticates to the server. This includes
authentication credentials, mechanism, source, and other settings.

If you don't specify an authentication mechanism, the driver uses either
SCRAM-SHA-1 or SCRAM-SHA-256, depending on the server version. See
authentication mechanisms for available
authentication mechanisms.

Data Type: MongoCredential
Default: null
Connection URI Example:

mongodb://user1:password1&authMechanism=GSSAPI
&authMechanismProperties=SERVICE_NAME:other,REALM:otherrealm
&authSource=$external

DirectConnection

Specifies whether to force dispatch all operations to the host.

If you specify this option, the driver doesn't accept the
DNS seed list connection format.
You must use the standard connection URI format
instead.

This property must be set to false if you specify more than one
host name.

Data Type: boolean
Default: false
Connection URI Example: directConnection=true

HeartbeatInterval

정기적인 서버 모니터링 검사 간격.
500 밀리초 이상이어야 합니다.

데이터 유형: TimeSpan
기본값: 10 초
연결 URI 예시: heartbeatFrequencyMS=5000

HeartbeatTimeout

모니터링 소켓이 시간 초과되기 전에 유휴 상태를 유지할 수 있는 시간입니다.

데이터 유형: TimeSpan
기본값: ConnectTimeout과 동일한 값
연결 URI 예시: heartbeatTimeoutMS=5000

IPv6

호스팅하다 주소가 IPv6 형식인지 여부를 지정합니다.

데이터 유형: boolean
기본값: false
연결 URI 예시: ipv6=true

IsFrozen

설정이 고정되었는지 여부를 나타냅니다. 고정 설정은 변경할 수 없습니다.
이 옵션은 읽기 전용입니다.

데이터 유형: boolean
기본값: false
연결 URI 예시: N/A

LinqProvider

The LINQ provider to use.

Data Type: LinqProvider
Default: LinqProvider.V3
Connection URI Example: N/A

로드 밸런싱

드라이버가 로드 밸런서에 연결하는지 여부를 지정합니다. 다음의 경우에만 이 속성을 true 으로 설정할 수 있습니다.

  • 호스트 이름을 하나만 지정합니다.

  • 복제본 세트에 연결하지 않습니다.

  • SrvMaxHosts 속성을 사용하고 있지 않습니다.

  • DirectConnection 속성을 사용하고 있지 않습니다.

데이터 유형: boolean
기본값: false
연결 URI 예시: loadBalanced=true

LocalThreshold

서버 자격에 대한 지연 시간 창입니다. 서버의 왕복 시간이 가장 빠른
서버의 왕복 시간에 이 값을 더한 값보다 긴 경우, 해당 서버는
선택할 수 없습니다.

데이터 유형: TimeSpan
기본값: 15 밀리초
연결 URL 예시: localThresholdMS=0

로깅 설정

The settings used for logging.

Data Type: LoggingSettings
Default: null
Connection URI Example: N/A

MaxConnecting

드라이버의 연결 풀이
동시에 설정할 수 있는 최대 연결 수입니다.

데이터 유형: integer
기본값: 2
연결 URI 예시: maxConnecting=3

MaxConnectionIdleTime

드라이버가 연결을 닫기 전에 연결이 유휴 상태로 지속될 수 있는 시간입니다.

데이터 유형: TimeSpan
기본값: 10 분
연결 URI 예시: maxIdleTimeMS=300000

MaxConnectionLifeTime

연결이 만료되기 전에 풀링할 수 있는 시간입니다.

데이터 유형: TimeSpan
기본값: 30 분
연결 URI 예시: maxLifetimeMS=50000

최대 연결 풀 크기

드라이버가 연결 풀에서 생성할 수 있는 최대 클라이언트 또는 연결 수입니다.
이 카운트에는 사용 중인 연결이 포함됩니다.

데이터 유형: integer
기본값: 100
연결 URI 예시: maxPoolSize=150

최소 연결 풀 크기

작업이 발생하지 않는 경우에도 드라이버가 연결 풀에서 생성하고 유지해야 하는 연결 수입니다.
이 카운트에는
사용 중인 연결이 포함됩니다.

데이터 유형: integer
기본값: 0
연결 URI 예시: minPoolSize=1

readConcern

The client's default read concern.
See read concern for more information.

Data Type: ReadConcern
Default: ReadConcern.Default
Connection URI Example: readConcernLevel=local

ReadEncoding

string 역직렬화에 사용할 UTF-8 인코딩입니다.
유효하지 않은 UTF- 바이트 시퀴언스가 발견되면 엄격한 인코딩은8
예외를 발생시킵니다.

데이터 유형: UTF8Encoding
기본값: 엄격한 인코딩
연결 URI 예시: N/A

읽기 설정

The client's default read-preference settings. MaxStaleness represents the
longest replication lag, in wall-clock time, that a secondary can experience and
still be eligible for server selection. Specifying -1 means no maximum.
See read preference for more information.

Data Type: ReadPreference
Default: ReadPreference.Primary
Connection URI Example:

readPreference=primaryPreferred
&maxStalenessSeconds=90
&readPreferenceTags=dc:ny,rack:1

연결 URI에 readPreferenceTags 매개변수를 두 번 이상 포함할 수 있습니다. 이 경우 클라이언트는 각 인스턴스를 별도의 태그 세트로 취급합니다. URI에 있는 태그의 순서에 따라 읽기 설정 순서가 결정됩니다. 이 매개 변수는 읽기 설정 모드가 primary가 아닌 경우에만 사용할 수 있습니다.

복제본 세트 이름

연결할 복제본 세트의 이름입니다.

데이터 유형: string
기본값: null
연결 URI 예시: replicaSet=yourReplicaSet

읽기 재시도

재시도 가능 읽기를 활성화합니다.

데이터 유형: boolean
기본값: true
연결 URI 예시: retryReads=false

RetryWrites

재시도 가능 쓰기를 활성화합니다.

데이터 유형: boolean
기본값: true
연결 URI 예시: retryWrites=false

Scheme

Specifies whether to use the standard connection string format (MongoDB)
or the DNS seed list format (MongoDBPlusSrv).
See the MongoDB Manual for more
information about connection string formats.

If the DirectConnection property is set to true and you
try to use the DNS seed list format, the .NET/C# Driver will throw an
exception.

Data Type: ConnectionStringScheme
Default: ConnectionStringScheme.MongoDB
Connection URI Example: mongodb+srv://

서버

The host and port number where MongoDB is running.

Data Type: MongoServerAddress
Default: localhost:27017
Connection URI Example: mongodb://sample.host:27017

서버API

Allows opting into Stable API versioning. See
the MongoDB Manual for more information about
Stable API versioning.

Data Type: ServerApi
Default: null
Connection URI Example: N/A

ServerMonitoringMode

Specifies the server monitoring protocol to use. When
this option is set to Auto, the monitoring mode is determined
by the environment in which the driver is running. The driver
uses polling mode in function-as-a-service (FaaS) environments,
such as AWS Lambda, and the streaming mode in other environments.

Data Type: ServerMonitoringMode
Default: Auto
Connection URI Example: serverMonitoringMode=poll

서버

The cluster members where MongoDB is running.

Data Type: IEnumerable<MongoServerAddress>
Default: localhost:27017
Connection URI Example: mongodb://sample.host1:27017,sample.host2:27017

ServerSelectionTimeout

드라이버가 시간이 초과되기 전에 서버 선택을 시도하는 시간입니다.

데이터 유형: TimeSpan
기본값: 30 초
연결 URI 예시: serverSelectionTimeoutMS=15000

소켓 타임아웃

드라이버가 시간이
초과되기 전에 소켓에서 전송 또는 수신을 시도하는 시간의 길이입니다.

데이터 유형: TimeSpan
기본값: OS 기본값
연결 URI 예시: socketTimeoutMS=0

SRVmax 호스트

시드 목록을 초기화할 때 또는 SRV 폴맅 중 토폴로지에 새 호스트를 추가할 때 무작위로 선택할 수 있는 SRV 결과의 최대 개수입니다.


연결 문자열 스키마가(으)로 설정된 경우에만 이 속성을 사용할 수
ConnectionStringScheme.MongoDBPlusSrv있습니다. 복제본 세트에 연결할 때는 사용할 수 없습니다.


데이터 유형: integer
기본값: 0
연결 URI 예시: srvMaxHosts=3

SrvServiceName

The service name of the SRV resource records
that the driver retrieves to construct your seedlist. This
property overrides the default service name for SRV lookup in
discovery and polling.

You can use this property only if the connection-string scheme is set
to ConnectionStringScheme.MongoDBPlusSrv. You cannot use it when connecting
to a replica set.

Data Type: string
Default: "mongodb"
Connection URI Example: srvServiceName="customname"

SslSettings

TLS/SSL options, including client certificates, revocation handling, and
enabled and disabled TLS/SSL protocols.

If SslSettings.CheckCertificateRevocation is set to false and
AllowInsecureTls is set to true, the .NET/C# Driver will throw
an exception.

Data Type: SslSettings
Default: null
Connection URI Example: tlsDisableCertificateRevocationCheck=false

UseTls

서버에 연결할 때 TLS를 요구할지 여부를 지정합니다.
"mongodb+srv" 의 스키마를 사용하거나 다른 TLS 옵션을
지정하면 이 옵션의 기본값은 true 이(가) 됩니다.

데이터 유형: boolean
기본값: false
연결 URI 예시: tls=true

대기열 시간 초과

운전자가 시간이
초과되기 전에 서버의 연결 풀에서 연결을 체크아웃하려고 시도하는 시간입니다.

데이터 유형: TimeSpan
기본값: 2 분
연결 URI 예시: waitQueueTimeoutMS=0

writeConcern

The default write-concern settings, including write timeout and
journaling, for the client.
See write concern for more information.

Data Type: WriteConcern
Default: WriteConcern.Acknowledged
Connection URI Example: w=majority&wTimeoutMS=0&journal=true

쓰기 인코딩

UTF-8 string 직렬화를 엄격하게 할지 관대하게 할지 지정합니다. 엄격한
인코딩을 사용하면 드라이버는 유효하지 않은
UTF-8 바이트 시큰스가 발견되면 예외를 발생시킵니다.

데이터 유형: UTF8Encoding
기본값: 엄격한 인코딩
연결 URI 예시: N/A