open62541: error/client GetEndpointRequest failed
Hi,
I encountered an issue in connecting with OPC server from Siemens 840D controller. Now, I do not try Wireshark to dump any traffic information.
[ Issue ] “GetEndpointRequest failed” and “No suitable endpoint found”.
[ Environments ] The OPC client was compiled and ran on the VMware machine. OS is Ubuntu 15. SDK version is v0.2-rc1 (open62541.c)
/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES
* visit http://open62541.org/ for information about this software
* Git-Revision: v0.2.0-RC1
*/
[ Description ] Source code of Client is an example from official website, and compiled with open62541.c.
#include <stdio.h>
#include <inttypes.h>
#include "open62541.h"
int main(void) {
UA_Client *client = UA_Client_new(UA_ClientConfig_standard);
UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:16664");
if(retval != UA_STATUSCODE_GOOD) {
UA_Client_delete(client);
return (int)retval;
}
//variables to store data
UA_DateTime raw_date = 0;
UA_String string_date;
/* create a readrequest with one entry */
UA_ReadRequest rReq;
UA_ReadRequest_init(&rReq);
rReq.nodesToRead = UA_Array_new(1, &UA_TYPES[UA_TYPES_READVALUEID]);
rReq.nodesToReadSize = 1;
/* define the node and attribute to be read */
#define NS0_CURRENT_TIME 2258
rReq.nodesToRead[0].nodeId = UA_NODEID_NUMERIC(0, NS0_CURRENT_TIME);
rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
/* call the service and print the result */
UA_ReadResponse rResp = UA_Client_Service_read(client, rReq);
if(rResp.responseHeader.serviceResult == UA_STATUSCODE_GOOD && rResp.resultsSize > 0 &&
rResp.results[0].hasValue && UA_Variant_isScalar(&rResp.results[0].value) &&
rResp.results[0].value.type == &UA_TYPES[UA_TYPES_DATETIME]) {
raw_date = *(UA_DateTime*)rResp.results[0].value.data;
printf("raw date is: %" PRId64 "\n", raw_date);
string_date = UA_DateTime_toString(raw_date);
printf("string date is: %.*s\n", (int)string_date.length, string_date.data);
}
UA_ReadRequest_deleteMembers(&rReq);
UA_ReadResponse_deleteMembers(&rResp);
UA_String_deleteMembers(&string_date);
UA_Client_disconnect(client);
UA_Client_delete(client);
return (int) UA_STATUSCODE_GOOD;
}
The Client could make connection with simulation server, but siemens controller.
EndpointUrl should be correct.
UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://192.168.10.101:48020");
[ Historical discussion] Thread #746 UA_Client_connect do not connected, which discussed the same issue, but I didn’t find an effective way to finish this issue.
Thanks for your help.
Kenny
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (6 by maintainers)
I can connect the siemens device ! 😆 just change the UA_ClientCOnfig_standard !