Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Adapter disconnect #460

Closed
neildes2 opened this issue Jun 12, 2024 · 25 comments · Fixed by #462 or #466
Closed

MQTT Adapter disconnect #460

neildes2 opened this issue Jun 12, 2024 · 25 comments · Fixed by #462 or #466
Assignees
Labels

Comments

@neildes2
Copy link
Collaborator

I have an v2.3.0.2 agent connected to a broker for mqtt ingress. Working great. But when it loses connection, shouldn't the agent set all tags to UNAVAILABLE? I have stale data for days.

@wsobel
Copy link
Member

wsobel commented Jun 12, 2024 via email

@neildes2
Copy link
Collaborator Author

neildes2 commented Jun 12, 2024

Devices = Devices.xml
AllowPut = true
AllowPutFrom = localhost
Port = 5000
ReconnectInterval = 1000
BufferSize = 17
MaxAssets = 1024
SchemaVersion = 2.3
ShdrVersion = 1
SuppressIPAddress = false
MonitorConfigFiles = false
WorkerThreads = 2
JsonVersion = 1
DisableAgentDevice = false
ConversionRequired = true
IgnoreTimestamps = true
Pretty = true
PreserveUUID=true
FilterDuplicates=yes

Adapters {

machine1 {
Url = mqtt://127.0.0.1/
MqttPort = 1883
MqttUserName = user1
MqttPassword = "p1"
Topics = "machine1/ingress/#"
MqttClientId = client-1

}
}

Logger Configuration

logger_config
{
logging_level = trace
}

@neildes2
Copy link
Collaborator Author

shdr adapter disconnect sets all tags to UNAVAILABLE.

2024-06-13T14:50:00.973341Z (0x000057d4) [debug] Connector::reader->Connector::reconnect->Connector::close: Disconnected from adapter, setting all values to UNAVAILABLE

But mqtt adapter (Broker) disconnect does not.

@neildes2
Copy link
Collaborator Author

Should this be a param? ON/OFF Use case...broker is 2nd adapter for sensors? USe case...Broker is primary adapter and should set all tags to UNAVAILABLE.

Maybe an adapter level parameter 'Primary=true'
Which ever adapter is the primary, if it gets disconnected, it sets all tags to UNAVAILABLE

@wsobel
Copy link
Member

wsobel commented Jun 13, 2024

This sounds reasonable behavior. I will take a look and see what it is doing now. May be a couple of days.

@wsobel wsobel added the bug label Jun 13, 2024
@wsobel wsobel self-assigned this Jun 13, 2024
@wsobel
Copy link
Member

wsobel commented Jun 13, 2024

The disconnect behavior is built into the agent. Must not be forwarding disconnect from broker signal.

Is this when the broker disconnects or when the source disconnects from the broker?

@neildes2
Copy link
Collaborator Author

In this test case, I pulled the network cable causing the disconnect from the broker. For the shdr test, I just turned off my local adapter.

@wsobel
Copy link
Member

wsobel commented Jun 13, 2024

Thanks. I'll disconnect my broker and test the behavior.

@wsobel
Copy link
Member

wsobel commented Jun 14, 2024

@neildes2 Please test

@wsobel wsobel reopened this Jun 14, 2024
@neildes2
Copy link
Collaborator Author

Downloading and testing now....

@wsobel wsobel closed this as completed Jun 17, 2024
@neildes2
Copy link
Collaborator Author

This issue is NOT resolved.

tested on Agent v2.3.0.11

All tags do NOT reset to UNAVAILABLE upon mqtt broker ingest disconnect.

@wsobel
Copy link
Member

wsobel commented Jun 17, 2024 via email

@neildes2
Copy link
Collaborator Author

when I tested the shdr adapter, the device AVAILABILITY tag went UNAVAILABLE. When I tested with broker adapter, it did not.

@wsobel
Copy link
Member

wsobel commented Jun 17, 2024 via email

@wsobel wsobel reopened this Jun 18, 2024
@neildes2
Copy link
Collaborator Author

The shdr adapter, when disconnected, set AVAILABILITY to UNAVAILABLE

@wsobel
Copy link
Member

wsobel commented Jun 18, 2024 via email

@neildes2
Copy link
Collaborator Author

Just tested v2.3.0.13. When I disable my wireless connection, the broker adapter disconnects and the agent states...."] MqttClientImpl::disconnected: Disconnected from adapter, setting all values to UNAVAILABLE". But the device Tags all remain stale at AVAILABILITY=AVAILABLE and EXECUTION = ACTIVE. Even the AGENT device AVAILABILITY remains AVAILABLE

@neildes2
Copy link
Collaborator Author

Devices = Devices.xml
AgentDeviceUUID = "3519a48b-814b-3425-a12d-ef250947ab3d"
PreserveUUID = true
Port = 5000
BufferSize = 17
MaxAssets = 1024
SchemaVersion = 2.2
ShdrVersion = 1
SuppressIPAddress = false
DisableAgentDevice = false
MonitorConfigFiles = false
WorkerThreads = 2
JsonVersion = 1
ConversionRequired = true
IgnoreTimestamps = true
Pretty = true
HeartBeat = 60000

@wsobel
Copy link
Member

wsobel commented Jun 19, 2024

Are you using the docker hub image?

@neildes2
Copy link
Collaborator Author

No. Downloading the WINDOWS compiled agent from this repo

@wsobel
Copy link
Member

wsobel commented Jun 19, 2024

Agent device should be available. If the agent is running.

@neildes2
Copy link
Collaborator Author

If I have TWO adapters defined that feed to one device, and only ONE of them gets disconnected, what happens?
If I have TWO adapters defined that feed to SEPARATE devices, and only ONE of them gets disconnected, what happens?

@wsobel
Copy link
Member

wsobel commented Jun 19, 2024

If two adapters are associated with the device, the data items set by each adapter will become unavailable if it disconnects. The others will not. Availability is controlled by the first adapter using AutoAvailable=true (default). This will allow the adapter to control the Availability data item.

I think any adapter with AutoAvailable true will try to set Availability when it disconnects. If availability is directly set by an adapter, then it will be associated with only that adapter.

The source of the data and the disconnect only effect the data items associated with the adapter. The code marks all data items and the last adapter they received data from.

@wsobel
Copy link
Member

wsobel commented Jun 19, 2024

Use AutoAvailable = true in the adapter config to make the Availability change to UNAVAILABLE when disconnected.

I found some issues with the adapter data item connection. Just created a new PR.

@wsobel wsobel linked a pull request Jun 19, 2024 that will close this issue
@neildes2
Copy link
Collaborator Author

works as expected now! Great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants