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

Error Code 0x8000 0000 in Response #2500

Open
6 of 7 tasks
alexhochreiter opened this issue Feb 25, 2019 · 0 comments
Open
6 of 7 tasks

Error Code 0x8000 0000 in Response #2500

alexhochreiter opened this issue Feb 25, 2019 · 0 comments

Comments

@alexhochreiter
Copy link

alexhochreiter commented Feb 25, 2019

Description

Cannot UA_Client_readValueAttribute(), returns error code 0x8000 0000 in response.

Background Information / Reproduction Steps

I copied the Code from the examples to read a remote server's node's data via OPC UA. The remote server does not support any type of encryption or other policies then None and the connection is authenticated with username and password credentials. For some strange reason, i cannot read any node's data, while UAExpert discovers and displays the data just fine.
As far as i could debug this, the function __UA_Client_readAttribute receives the response, which has a resultsSize of 1 and a result.value which only containts zero'd values (see debugger screenshot attached).
The status of the result is d2147483648 or h0x80 00 00 00 or b1000 0000 0000 0000 0000 0000 0000 0000 for which i could not find a matching error code in the amalgamated header file. (I am using both, the amalgamated source and header file in every recompile as i had to backport those files to AIX 7, but couldnt get this library working at all on neither windows 10 nor ubuntu 18.10 yet)

opcua_debugger_screenshot

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag): 85b419a
  • Other OPC UA SDKs used (client or server): none, raw C++
  • Operating system: Windows 10, Ubuntu 18.10, AIX 7.3
  • Logs (with UA_LOGLEVEL set as low as necessary) attached
  • Wireshark network dump attached
  • Self-contained code example attached
  • Critical issue

Used code, copied & butchered frankenstein from the examples. Only incldued QtGlobal for the Q_UNUSED as i am using QtCreator anyways. Source code matches wireshark recording.

#include <opcua/open62541.h>
#include <QtGlobal>

int main(int argc, char *argv[]) {
    Q_UNUSED(argc)
    Q_UNUSED(argv)
    UA_Client *client = UA_Client_new();
    UA_ClientConfig_setDefault(UA_Client_getConfig(client));

    /* Listing endpoints */
    UA_EndpointDescription* endpointArray = NULL;
    size_t endpointArraySize = 0;
    UA_StatusCode retval = UA_Client_getEndpoints(client, "opc.tcp:https://172.16.2.89:4840", &endpointArraySize, &endpointArray);
    if((unsigned short)retval != (unsigned short)UA_STATUSCODE_GOOD) {
        printf("Listing Endpoints failed. ErroNo: %d\n", retval);
        UA_Array_delete(endpointArray, endpointArraySize, &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
        UA_Client_delete(client);
        return EXIT_FAILURE;
    }
    printf("%i endpoints found\n", (int)endpointArraySize);
    for(size_t i=0;i<endpointArraySize;i++) {
        printf("URL of endpoint %i is %.*s\n", (int)i,
               (int)endpointArray[i].endpointUrl.length,
               endpointArray[i].endpointUrl.data);
    }

    /* Connect to a server */
    UA_ClientConfig* config = UA_Client_getConfig(client);
    UA_ClientConfig_setDefault(config);
    config->endpoint = endpointArray[1];
    // UA_ClientConfig * client_config = UA_Client_getConfig(client);
    retval = UA_Client_connect_username(client, "opc.tcp:https://172.16.2.89:4840", "user", "password");
    if(retval != UA_STATUSCODE_GOOD) {
        UA_Client_delete(client);
        printf("Connection failed.\n");
        return (int)retval;
    }

    printf("\nReading value ...\n");
    UA_Variant val;
    UA_Variant_init(&val);

    UA_NodeId nodeId = UA_NODEID_STRING_ALLOC(2, "ActualBoiler");
    retval = UA_Client_readValueAttribute(client, nodeId, &val);

    if(retval == UA_STATUSCODE_GOOD) {
        printf("ok");
    } else {
        printf(":(");
    }

    // retval = UA_Client_readValueAttribute(client, UA_NODEID_STRING(2, "ActualBoiler"), val);
    // retval = UA_Client_readValueAttribute(client, UA_NODEID_NUMERIC(2, 163), val);
    retval = UA_Client_readValueAttribute(client, nodeId, &val);

    printf("retval: %x == %d\nUA_Variant_isScalar(val): %d\n", retval, UA_STATUSCODE_GOOD, UA_Variant_isScalar(&val));
    if(retval == UA_STATUSCODE_GOOD) {
        UA_String strval = *(UA_String*)val.data;
        printf("\tOutput UAstring: " UA_PRINTF_STRING_FORMAT "\n", UA_PRINTF_STRING_DATA(strval));
    } else {
        printf("\nNo value returned :,(\n\n");
    }
    UA_Client_delete(client); /* Disconnects the client internally */
    return UA_STATUSCODE_GOOD;
}

Printed log with #define UA_LOGLEVEL 0

[2019-02-25 16:00:15.419 (UTC+0100)] debug/client       Initialize the SecurityPolicy context
[2019-02-25 16:00:15.419 (UTC+0100)] warn/securitypolicy        No PKI plugin set. Accepting all certificates
[2019-02-25 16:00:15.434 (UTC+0100)] info/client        TCP connection established
[2019-02-25 16:00:15.434 (UTC+0100)] debug/network      Sent HEL message
[2019-02-25 16:00:15.434 (UTC+0100)] debug/network      Received ACK message
[2019-02-25 16:00:15.434 (UTC+0100)] debug/channel      Requesting to open a SecureChannel
[2019-02-25 16:00:15.434 (UTC+0100)] debug/channel      OPN message sent
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Decrypting chunk
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Chunk size before and after decryption: 136, 136
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Verifying chunk signature
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Decrypted and verified chunk with request id 1 and sequence number 51
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Sequence Number processed: 51
[2019-02-25 16:00:15.434 (UTC+0100)] debug/client       Decode a message of type OpenSecureChannelResponse
[2019-02-25 16:00:15.434 (UTC+0100)] info/client        Opened SecureChannel with SecurityPolicy http:https://opcfoundation.org/UA/SecurityPolicy#None
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Generating new local keys
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Generating new remote keys
[2019-02-25 16:00:15.434 (UTC+0100)] debug/client       Sending a request of type 426
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Decrypting chunk
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Chunk size before and after decryption: 2886, 2886
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Decrypted and verified chunk with request id 2 and sequence number 52
[2019-02-25 16:00:15.434 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747725 | Sequence Number processed: 52
[2019-02-25 16:00:15.434 (UTC+0100)] debug/client       Decode a message of type GetEndpointsResponse
2 endpoints found
URL of endpoint 0 is opc.tcp:https://Compact:4840
URL of endpoint 1 is opc.tcp:https://Compact:4840
[2019-02-25 16:00:15.434 (UTC+0100)] error/network      Could not initialize a config that already has SecurityPolicies
[2019-02-25 16:00:15.434 (UTC+0100)] info/client        Connecting to endpoint opc.tcp:https://172.16.2.89:4840
[2019-02-25 16:00:15.434 (UTC+0100)] debug/client       Initialize the SecurityPolicy context
[2019-02-25 16:00:15.434 (UTC+0100)] warn/securitypolicy        No PKI plugin set. Accepting all certificates
[2019-02-25 16:00:15.434 (UTC+0100)] info/client        TCP connection established
[2019-02-25 16:00:15.434 (UTC+0100)] debug/network      Sent HEL message
[2019-02-25 16:00:15.450 (UTC+0100)] debug/network      Received ACK message
[2019-02-25 16:00:15.450 (UTC+0100)] debug/channel      Requesting to open a SecureChannel
[2019-02-25 16:00:15.450 (UTC+0100)] debug/channel      OPN message sent
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Decrypting chunk
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Chunk size before and after decryption: 136, 136
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Verifying chunk signature
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Decrypted and verified chunk with request id 1 and sequence number 51
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel 0 | Sequence Number processed: 51
[2019-02-25 16:00:15.450 (UTC+0100)] debug/client       Decode a message of type OpenSecureChannelResponse
[2019-02-25 16:00:15.450 (UTC+0100)] info/client        Opened SecureChannel with SecurityPolicy http:https://opcfoundation.org/UA/SecurityPolicy#None
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Generating new local keys
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Generating new remote keys
[2019-02-25 16:00:15.450 (UTC+0100)] debug/client       Create a new session
[2019-02-25 16:00:15.450 (UTC+0100)] debug/client       Sending a request of type 459
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypting chunk
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Chunk size before and after decryption: 3924, 3924
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypted and verified chunk with request id 2 and sequence number 52
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Sequence Number processed: 52
[2019-02-25 16:00:15.450 (UTC+0100)] debug/client       Decode a message of type CreateSessionResponse
[2019-02-25 16:00:15.450 (UTC+0100)] debug/client       Sending a request of type 465
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypting chunk
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Chunk size before and after decryption: 64, 64
[2019-02-25 16:00:15.450 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypted and verified chunk with request id 3 and sequence number 53
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Sequence Number processed: 53
[2019-02-25 16:00:15.466 (UTC+0100)] debug/client       Decode a message of type ActivateSessionResponse

Reading value ...
[2019-02-25 16:00:15.466 (UTC+0100)] debug/client       Sending a request of type 629
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypting chunk
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Chunk size before and after decryption: 81, 81
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypted and verified chunk with request id 4 and sequence number 54
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Sequence Number processed: 54
[2019-02-25 16:00:15.466 (UTC+0100)] debug/client       Decode a message of type ReadResponse
:([2019-02-25 16:00:15.466 (UTC+0100)] debug/client     Sending a request of type 629
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypting chunk
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Chunk size before and after decryption: 81, 81
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypted and verified chunk with request id 5 and sequence number 55
[2019-02-25 16:00:15.466 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Sequence Number processed: 55
[2019-02-25 16:00:15.466 (UTC+0100)] debug/client       Decode a message of type ReadResponse
retval: 80000000 == 0
UA_Variant_isScalar(val): 0

No value returned :,(

[2019-02-25 16:00:15.481 (UTC+0100)] debug/client       Sending a request of type 471
[2019-02-25 16:00:15.481 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypting chunk
[2019-02-25 16:00:15.481 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Chunk size before and after decryption: 52, 52
[2019-02-25 16:00:15.481 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Decrypted and verified chunk with request id 6 and sequence number 56
[2019-02-25 16:00:15.481 (UTC+0100)] trace/channel      Connection 272 | SecureChannel -60747724 | Sequence Number processed: 56
[2019-02-25 16:00:15.481 (UTC+0100)] debug/client       Decode a message of type CloseSessionResponse

opcua_wireshark_sniff_2019_02_25.zip

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

No branches or pull requests

1 participant