public final class AwsIotMqttConnectionBuilder
extends software.amazon.awssdk.crt.CrtResource
| Modifier and Type | Method and Description |
|---|---|
software.amazon.awssdk.crt.mqtt.MqttClientConnection |
build()
Builds a new mqtt connection from the configuration stored in the builder.
|
static AwsIotMqttConnectionBuilder |
newDefaultBuilder()
Create a new builder with no default Tls options
|
static AwsIotMqttConnectionBuilder |
newMtlsBuilder(byte[] certificate,
byte[] privateKey)
Create a new builder with mTLS cert pair in memory
|
static AwsIotMqttConnectionBuilder |
newMtlsBuilder(String certificate,
String privateKey)
Create a new builder with mTLS cert pair in memory
|
static AwsIotMqttConnectionBuilder |
newMtlsBuilderFromPath(String certPath,
String privateKeyPath)
Create a new builder with mTLS file paths
|
static AwsIotMqttConnectionBuilder |
newMtlsPkcs11Builder(software.amazon.awssdk.crt.io.TlsContextPkcs11Options pkcs11Options)
Create a new builder with mTLS, using a PKCS#11 library for private key operations.
|
static AwsIotMqttConnectionBuilder |
newMtlsWindowsCertStorePathBuilder(String certificatePath)
Create a new builder with mTLS, using a certificate in a Windows certificate store.
|
AwsIotMqttConnectionBuilder |
withBootstrap(software.amazon.awssdk.crt.io.ClientBootstrap bootstrap)
Configures the client bootstrap to use for connections created by this builder
|
AwsIotMqttConnectionBuilder |
withCertificateAuthority(String caRoot)
Overrides the default system trust store.
|
AwsIotMqttConnectionBuilder |
withCertificateAuthorityFromPath(String caDirPath,
String caFilePath)
Overrides the default system trust store.
|
AwsIotMqttConnectionBuilder |
withCleanSession(boolean cleanSession)
Configures whether or not the service should try to resume prior
subscriptions, if it has any
|
AwsIotMqttConnectionBuilder |
withClientId(String clientId)
Configures the client id to use to connect to the IoT Core service.
|
AwsIotMqttConnectionBuilder |
withConnectionEventCallbacks(software.amazon.awssdk.crt.mqtt.MqttClientConnectionEvents callbacks)
Configures the connection-related callbacks to use for connections created by this builder
|
AwsIotMqttConnectionBuilder |
withCustomAuthorizer(String username,
String authorizerName,
String authorizerSignature,
String password)
Configures the MQTT connection so it can use a custom authorizer.
|
AwsIotMqttConnectionBuilder |
withEndpoint(String endpoint)
Configures the IoT endpoint for connections from this builder.
|
AwsIotMqttConnectionBuilder |
withHttpProxyOptions(software.amazon.awssdk.crt.http.HttpProxyOptions proxyOptions)
Configures any http proxy options to use
|
AwsIotMqttConnectionBuilder |
withKeepAliveMs(int keepAliveMs)
Deprecated.
Configures MQTT keep-alive via PING messages. Note that this is not TCP
keepalive.
|
AwsIotMqttConnectionBuilder |
withKeepAliveSecs(int keepAliveSecs)
Configures MQTT keep-alive via PING messages.
|
AwsIotMqttConnectionBuilder |
withPassword(String password)
Configures the password to include in the initial CONNECT mqtt packet for connections created by this builder.
|
AwsIotMqttConnectionBuilder |
withPingTimeoutMs(int pingTimeoutMs)
Controls ping timeout value.
|
AwsIotMqttConnectionBuilder |
withPort(short port)
Configures the port to connect to for connections from this builder.
|
AwsIotMqttConnectionBuilder |
withProtocolOperationTimeoutMs(int protocolOperationTimeoutMs)
Controls timeout value for requests that response is required on healthy connection.
|
AwsIotMqttConnectionBuilder |
withReconnectTimeoutSecs(long minTimeoutSecs,
long maxTimeoutSecs)
Configures the minimum and maximum reconnect timeouts.
|
AwsIotMqttConnectionBuilder |
withSocketOptions(software.amazon.awssdk.crt.io.SocketOptions socketOptions)
Configures the common settings for the socket to use for connections created by this builder
|
AwsIotMqttConnectionBuilder |
withTimeoutMs(int timeoutMs)
Configures the TCP socket connect timeout (in milliseconds)
|
AwsIotMqttConnectionBuilder |
withUsername(String username)
Configures the username to include in the initial CONNECT mqtt packet for connections created by this builder.
|
AwsIotMqttConnectionBuilder |
withWebsocketCredentialsProvider(software.amazon.awssdk.crt.auth.credentials.CredentialsProvider provider)
Configures the credentials provider to use for websocket handshake signing.
|
AwsIotMqttConnectionBuilder |
withWebsocketHandshakeTransform(Consumer<software.amazon.awssdk.crt.mqtt.WebsocketHandshakeTransformArgs> handshakeTransform)
Configures handshake transform used when establishing a connection via websockets.
|
AwsIotMqttConnectionBuilder |
withWebsocketProxyOptions(software.amazon.awssdk.crt.http.HttpProxyOptions proxyOptions)
Deprecated.
use withHttpProxyOptions instead
Configures any http proxy options to use if the connection uses websockets
|
AwsIotMqttConnectionBuilder |
withWebsockets(boolean useWebsockets)
Configures whether or not to the connection uses websockets
|
AwsIotMqttConnectionBuilder |
withWebsocketSigningRegion(String region)
Configures the region to use when signing (via Sigv4) the websocket upgrade request.
|
AwsIotMqttConnectionBuilder |
withWill(software.amazon.awssdk.crt.mqtt.MqttMessage message)
Sets the last will and testament message to be delivered to a topic when a connection created by this builder
disconnects
|
AwsIotMqttConnectionBuilder |
withWill(software.amazon.awssdk.crt.mqtt.MqttMessage message,
software.amazon.awssdk.crt.mqtt.QualityOfService qos,
boolean retain)
Deprecated.
Use alternate withWill(). QoS and retain are now set directly on the
MqttMessage |
public static AwsIotMqttConnectionBuilder newMtlsBuilderFromPath(String certPath, String privateKeyPath)
certPath - - Path to certificate, in PEM formatprivateKeyPath - - Path to private key, in PEM formatAwsIotMqttConnectionBuilderpublic static AwsIotMqttConnectionBuilder newMtlsBuilder(String certificate, String privateKey)
certificate - - Certificate, in PEM formatprivateKey - - Private key, in PEM formatAwsIotMqttConnectionBuilderpublic static AwsIotMqttConnectionBuilder newMtlsBuilder(byte[] certificate, byte[] privateKey) throws UnsupportedEncodingException
certificate - - Certificate, in PEM formatprivateKey - - Private key, in PEM formatAwsIotMqttConnectionBuilderUnsupportedEncodingException - if encoding is unsupportedpublic static AwsIotMqttConnectionBuilder newMtlsPkcs11Builder(software.amazon.awssdk.crt.io.TlsContextPkcs11Options pkcs11Options)
pkcs11Options - PKCS#11 optionsAwsIotMqttConnectionBuilderpublic static AwsIotMqttConnectionBuilder newMtlsWindowsCertStorePathBuilder(String certificatePath)
certificatePath - Path to certificate in a Windows certificate store.
The path must use backslashes and end with the
certificate's thumbprint. Example:
CurrentUser\MY\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6AwsIotMqttConnectionBuilderpublic static AwsIotMqttConnectionBuilder newDefaultBuilder() throws UnsupportedEncodingException
UnsupportedEncodingException - if encoding is unsupportedpublic AwsIotMqttConnectionBuilder withCertificateAuthorityFromPath(String caDirPath, String caFilePath)
caDirPath - - Only used on Unix-style systems where all trust anchors
are stored in a directory (e.g. /etc/ssl/certs).caFilePath - - Single file containing all trust CAs, in PEM formatAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withCertificateAuthority(String caRoot)
caRoot - - Buffer containing all trust CAs, in PEM formatAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withEndpoint(String endpoint)
endpoint - The IoT endpoint to connect toAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withPort(short port)
port - The port to connect to on the IoT endpoint. Usually 8883 for
MQTT, or 443 for websocketsAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withClientId(String clientId)
clientId - The client id for connections from this builder. Needs to be unique across
all devices/clients.AwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withCleanSession(boolean cleanSession)
cleanSession - true if the session should drop prior subscriptions when
a connection from this builder is established, false to resume the sessionAwsIotMqttConnectionBuilder@Deprecated public AwsIotMqttConnectionBuilder withKeepAliveMs(int keepAliveMs)
keepAliveMs - How often in milliseconds to send an MQTT PING message to the
service to keep connections aliveAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withKeepAliveSecs(int keepAliveSecs)
keepAliveSecs - How often in seconds to send an MQTT PING message to the
service to keep connections aliveAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withPingTimeoutMs(int pingTimeoutMs)
pingTimeoutMs - How long to wait for a ping response before resetting a connection built from this
builder.AwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withProtocolOperationTimeoutMs(int protocolOperationTimeoutMs)
protocolOperationTimeoutMs - How long to wait for a request response (in milliseconds) before failingAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withTimeoutMs(int timeoutMs)
timeoutMs - TCP socket timeoutAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withReconnectTimeoutSecs(long minTimeoutSecs, long maxTimeoutSecs)
minTimeoutSecs - The timeout to start withmaxTimeoutSecs - The highest allowable wait time between reconnect attemptsAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withSocketOptions(software.amazon.awssdk.crt.io.SocketOptions socketOptions)
socketOptions - The socket settingsAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withUsername(String username)
username - username to use in CONNECTAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withPassword(String password)
password - password to use in CONNECTAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withConnectionEventCallbacks(software.amazon.awssdk.crt.mqtt.MqttClientConnectionEvents callbacks)
callbacks - connection event callbacks to useAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWill(software.amazon.awssdk.crt.mqtt.MqttMessage message) throws software.amazon.awssdk.crt.mqtt.MqttException
message - The message to publish as the will. The message contains the
topic that the message will be published to on disconnect,
along with the QualityOfService that it will be
published with and whether it will be retained when it is published.AwsIotMqttConnectionBuildersoftware.amazon.awssdk.crt.mqtt.MqttException@Deprecated public AwsIotMqttConnectionBuilder withWill(software.amazon.awssdk.crt.mqtt.MqttMessage message, software.amazon.awssdk.crt.mqtt.QualityOfService qos, boolean retain) throws software.amazon.awssdk.crt.mqtt.MqttException
MqttMessagemessage - deprecatedqos - deprecatedretain - depricatedAwsIotMqttConnectionBuildersoftware.amazon.awssdk.crt.mqtt.MqttExceptionpublic AwsIotMqttConnectionBuilder withBootstrap(software.amazon.awssdk.crt.io.ClientBootstrap bootstrap)
bootstrap - client bootstrap to use for created connectionsAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWebsockets(boolean useWebsockets)
useWebsockets - whether or not to use websocketsAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWebsocketHandshakeTransform(Consumer<software.amazon.awssdk.crt.mqtt.WebsocketHandshakeTransformArgs> handshakeTransform)
handshakeTransform - handshake request transformation functionAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWebsocketProxyOptions(software.amazon.awssdk.crt.http.HttpProxyOptions proxyOptions)
proxyOptions - http proxy options to use when establishing a websockets-based connectionAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withHttpProxyOptions(software.amazon.awssdk.crt.http.HttpProxyOptions proxyOptions)
proxyOptions - http proxy options to use when establishing a connectionAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWebsocketSigningRegion(String region)
region - region to use when signing the websocket upgrade requestAwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withWebsocketCredentialsProvider(software.amazon.awssdk.crt.auth.credentials.CredentialsProvider provider)
provider - credentials provider to pull Aws credentials from.AwsIotMqttConnectionBuilderpublic AwsIotMqttConnectionBuilder withCustomAuthorizer(String username, String authorizerName, String authorizerSignature, String password)
username - The username to use with the custom authorizer. If null is passed, it will check to
see if a username has already been set (via withUsername function). If no username is set then
no username will be passed with the MQTT connection.authorizerName - The name of the custom authorizer. If null is passed, then 'x-amz-customauthorizer-name'
will not be added with the MQTT connection.authorizerSignature - The signature of the custom authorizer. If null is passed, then 'x-amz-customauthorizer-signature'
will not be added with the MQTT connection.password - The password to use with the custom authorizer. If null is passed, then no password will be set.public software.amazon.awssdk.crt.mqtt.MqttClientConnection build()
Copyright ? 2021. All rights reserved.