Table of Contents

Delegate ConnectionTransportFactory

Namespace
RabbitMQ.AMQP.Client
Assembly
RabbitMQ.AMQP.Client.dll

Produces the connected, plain (not encrypted) duplex stream a connection will run on, in place of the socket the library would otherwise open itself.

This is the seam for reaching a broker that is not directly dialable - most commonly a socket tunnelled through an HTTP CONNECT proxy. TLS is not the factory's job: when the scheme is amqps the library negotiates TLS over the returned stream using TlsSettings, and validates the broker certificate against Host. The certificate is therefore checked against the broker's real name, not against the address the factory had to dial.

The factory is invoked once per connection attempt, including every recovery attempt, so it must return a freshly connected stream each time. Ownership of the stream passes to the connection, which disposes it when the connection closes.

public delegate Task<Stream> ConnectionTransportFactory(string host, int port, CancellationToken cancellationToken)

Parameters

host string

The broker host from the connection settings, unresolved.

port int

The broker port from the connection settings.

cancellationToken CancellationToken

Token to cancel establishing the transport.

Returns

Task<Stream>

A task whose result is a connected duplex stream to host.