Skip to content

What is keep_alive_timeout_sec ? #11

Closed
@amitguptaRean

Description

@amitguptaRean

Please refer to socket options that are used in mqttClient->NewConnection (Refer to code snippet below)
What does it do ?
How does it differs from keep_alive_interval ?

socketOptions.connect_timeout_ms = 3000;
socketOptions.domain = AWS_SOCKET_IPV4;
socketOptions.type = AWS_SOCKET_STREAM;
socketOptions.keep_alive_interval_sec = this->mqttConfiguration.keep_alive_interval_sec; //30
**socketOptions.keep_alive_timeout_sec = this->mqttConfiguration.keep_alive_interval_sec; //30**
socketOptions.keepalive = true;

///*
	// * Now create a connection object. Note: This type is move only
	// * and its underlying memory is managed by the client.
	// */
	mqttConnection = mqttClient->NewConnection(endpoint.c_str(), port, socketOptions, connectionOptions);

	if (!*mqttConnection)
	{
		fprintf(stderr, "MQTT Connection Creation failed with error %s\n", ErrorDebugString(mqttConnection->LastError()));
		return MQTT_CONNECTION_CREATION_FAILED;
	}

/*
	 * Connect -> Persistent session
	 When a client requests the server to hold session data, the client is responsible for storing the following information:
	 All messages in a QoS 1 or 2 flow, that are not yet confirmed by the broker.
	 All QoS 2 messages received from the broker that are not yet completely acknowledged.
	*/
	if (!mqttConnection->Connect(clientId.c_str(), false, mqttConfiguration.keep_alive_interval_sec))
	{
		fprintf(stderr, "MQTT Connection failed with error %s\n", ErrorDebugString(mqttConnection->LastError()));
		return FAILURE_CONNECT;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidanceQuestion that needs advice or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions