Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Dear All!
How best to check whether the agent is currently connected to the enterprise?
What comes to my mind:
- parsing log messages in xgate.log
- creating a handshake between agent and enterprise by installing some mechanism, like setting and checking DataItems in turn
- using a function like "CheckNewPackages" with a fake package I created on the Enterprise, where I have to make sure that that is never applied
There should be an easier way?
I am asking since (corporate environment) we want to check user's proxy settings and overall connectivity to give him feedback. (We are buidling our own wrapper around the agent configuration functionality to give the user a more consolidated experience.)
Many thanks
andipandi
Isn't there a Logic Schema trigger for Internet connected?
This trigger fires when the Internet (Web) system is online and ready for use.
Ask Dmitriy Khodos if this fires when it is possible to post or when the Agent actually gets responses from the Enterprise.
The Deployment Utility has a way to know if the Agent is connected to the Enterprise. Perhaps you could exploit that mechanism through an extension.
Hi
Randy Thompson from my prev conversation with Jim K the Internet Connected informs if the Agent is sending out information to the Platform and it does not indicate if Agent receives the response. But I may be wrong. Dmitriy Khodos would know!
Dear Randy and Maciej!
Many thanks for your input!
Best
Andreas
You could develop a custom component for the Agent in C++ and use it to query the Enterprise connectivity status. The API call that your component would have to make is IEnterpriseProxy::GetServerStatus(). A pointer to the IEnterpriseProxy interface can be obtained by calling GetInterface() with IID_ENTERPRISE_PROXY argument. See CustomComponent/SampleComponents in the Agent SDK for examples of custom component source code.
Dear Dimitry!
Thanks for your input!
We already have a custom component developed by Axeda, so (not knowing whether IEnterpriseProxy is COM, in-process, out-of-process, ...) I decided to extend that component (it also already has member of IEnterpriseProxy) and then (also adding this DI through Builder project) add my own DataItem.
The design seems not to be 100%ly elegant, but it does the job.
For usage, I have to set the DataItem with a "T" value, wait a bit, and then either get an "N" or an "F" (also not sure about AX_Char being wchar or something else, also unsure about allowed size of string, so I just limit to 1 char..).
I tested this and saw that I get the desired result (there is some delay when unplugging network, I suppose this is based on the ping rate currently set - can I force a connection attempt?).
Many thanks, best
Andreas
/////////////////////////////////////////////////////////////////////////////
//
// OnDataChange() Handle data change
//
/////////////////////////////////////////////////////////////////////////////
void StateChange::OnDataChange(int count, AX_DataItem* pItems)
{
AX_Char myResChars[64];
for (int i = 0; i < count; i++)
{
AX_DataItem* pItem = &pItems;
EString strDataItem = pItem->pszName;
if(strDataItem == /* ... */)
{
// ... existing code
}
else if(strDataItem == AGENT_QUERY_ONLINE)
{
AX_DataValue *pValue = &pItem->value;
if(pValue->iQuality == AX_DataGood && pValue->iType == AX_DataString)
{
AX_Char* pCh = pValue->data.pszString;
if (*pCh != 0)
{
if (*pCh == (AX_Char)TEXT('T')) // T == Test
{
AX_DataItem Item;
Item.iDeviceId = CONNECTOR_GATEWAY; // AgentQueryOnline data item lives on the Gateway
Item.pszName = (AX_Char*)AGENT_QUERY_ONLINE;
Item.bInhibit = AX_False;
Item.value.iType = AX_DataString;
Item.value.iQuality = AX_DataGood;
Item.value.timeStamp.iSec = time(NULL);
Item.value.timeStamp.iMilliSec = 0;
bool online;
this->m_pEnterprise->GetServerStatus(&online);
if (online)
myResChars[0]= (AX_Char)TEXT('N'); // N == oNline
else
myResChars[0]= (AX_Char)TEXT('F'); // F == oFfline
myResChars[1] = 0;
Item.value.data.pszString = myResChars;
AX_SetDataItems(1, &Item);
}
}
}
}
}
}
AX_Char represents "wide" character.
The Agent determines that the Enterprise server is unavailable -- that is, the connectivity state is offline -- once three successive communication attempts have failed. Moreover, when the Agent encounters a communication failure, the next attempt is delayed for a period of time randomized between 0 and 60 seconds. This is why IEnterpriseProxy::GetServerStatus() may not reflect loss of connectivity for a minute a two after the connection has been disrupted.
Hello Dmitriy!
Thanks again.
Looks like I can also force the desired behavior (results with maybe 10-20s delay) by restarting the axedagateway service and then checking straight away.
I will also test whether I can get the same by doing the soft restart through web service.
Best
Andreas
When you restart the Gateway service, it is like starting the agent from beginning. Any data items or software management packages being held in memory will be lost.