Skip to content

Commit

Permalink
Merge pull request #439 from mtconnect/438_mqtt_ingress_issues_on_cur…
Browse files Browse the repository at this point in the history
…rent_build

Fixed port in url for MQTT service.
  • Loading branch information
wsobel authored Apr 12, 2024
2 parents e6f9692 + 0dd7ed9 commit fb69dca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 3)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 6)
set(AGENT_VERSION_BUILD 7
)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
Expand Down
29 changes: 29 additions & 0 deletions src/mtconnect/mqtt/mqtt_client_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace mtconnect {
m_connected = false;
if (m_handler && m_handler->m_disconnected)
m_handler->m_disconnected(shared_from_this());
m_handler->m_disconnected(shared_from_this());
if (m_running)
{
reconnect();
Expand Down Expand Up @@ -235,6 +236,7 @@ namespace mtconnect {
{
client->async_disconnect(10s, [client, url](mqtt::error_code ec) {
LOG(warning) << url << " disconnected: " << ec.message();
client->set_close_handler(nullptr);
});

client.reset();
Expand Down Expand Up @@ -411,6 +413,13 @@ namespace mtconnect {
public:
using base = MqttClientImpl<MqttTcpClient>;
using base::base;
/// @brief Get a shared pointer to this
/// @return shared pointer to this
shared_ptr<MqttTcpClient> getptr()
{
return static_pointer_cast<MqttTcpClient>(shared_from_this());
}

/// @brief Get the Mqtt TCP Client
/// @return pointer to the Mqtt TCP Client
auto &getClient()
Expand All @@ -437,6 +446,12 @@ namespace mtconnect {
public:
using base = MqttClientImpl<MqttTlsClient>;
using base::base;
/// @brief Get a shared pointer to this
/// @return shared pointer to this
shared_ptr<MqttTlsClient> getptr()
{
return static_pointer_cast<MqttTlsClient>(shared_from_this());
}

/// @brief Get the Mqtt TLS Client
/// @return pointer to the Mqtt TLS Client
Expand Down Expand Up @@ -480,6 +495,13 @@ namespace mtconnect {
public:
using base = MqttClientImpl<MqttTlsWSClient>;
using base::base;
/// @brief Get a shared pointer to this
/// @return shared pointer to this
shared_ptr<MqttTlsWSClient> getptr()
{
return static_pointer_cast<MqttTlsWSClient>(shared_from_this());
}

/// @brief Get the Mqtt TLS WebSocket Client
/// @return pointer to the Mqtt TLS WebSocket Client
auto &getClient()
Expand Down Expand Up @@ -512,6 +534,13 @@ namespace mtconnect {
public:
using base = MqttClientImpl<MqttWSClient>;
using base::base;
/// @brief Get a shared pointer to this
/// @return shared pointer to this
shared_ptr<MqttWSClient> getptr()
{
return static_pointer_cast<MqttWSClient>(shared_from_this());
}

/// @brief Get the Mqtt TLS WebSocket Client
/// @return pointer to the Mqtt TLS WebSocket Client
auto &getClient()
Expand Down
11 changes: 3 additions & 8 deletions src/mtconnect/source/adapter/mqtt/mqtt_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@ namespace mtconnect {
{
m_options[configuration::MqttHost] = m_options[configuration::Host];
}
if (!HasOption(m_options, configuration::MqttPort) &&
HasOption(m_options, configuration::Port))
{
m_options[configuration::MqttPort] = m_options[configuration::Port];
}
else
if (!HasOption(m_options, configuration::MqttPort))
{
m_options[configuration::MqttPort] = 1883;
}
Expand Down Expand Up @@ -123,7 +118,7 @@ namespace mtconnect {
!IsOptionSet(m_options, configuration::MqttWs))
{
m_client = make_shared<mtconnect::mqtt_client::MqttTlsClient>(m_ioContext, m_options,
move(clientHandler));
std::move(clientHandler));
}
else if (IsOptionSet(m_options, configuration::MqttWs) &&
IsOptionSet(m_options, configuration::MqttTls))
Expand All @@ -139,7 +134,7 @@ namespace mtconnect {
else
{
m_client = make_shared<mtconnect::mqtt_client::MqttTcpClient>(m_ioContext, m_options,
move(clientHandler));
std::move(clientHandler));
}

m_identity = m_client->getIdentity();
Expand Down

0 comments on commit fb69dca

Please sign in to comment.