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

BadEncodingError for long strings #1847

Open
4 of 7 tasks
dapaulid opened this issue Jun 13, 2018 · 0 comments
Open
4 of 7 tasks

BadEncodingError for long strings #1847

dapaulid opened this issue Jun 13, 2018 · 0 comments

Comments

@dapaulid
Copy link
Contributor


Description

The library fails to encode long strings (512 bytes in my tests), resulting in a BadEncodingError.

As a workaround, I had to increase UA_VALUENCODING_MAXSTACK accordingly, which of course is not adequate for embedded systems with limited stack sizes.

Maybe there is any issue in the chunking strategy? Or are there any limits imposed on individual variables?

Background Information / Reproduction Steps

Server code reproducing the Issue:

int main(void) {
    signal(SIGINT, stopHandler);
    signal(SIGTERM, stopHandler);

    UA_ServerConfig *config = UA_ServerConfig_new_default();
    UA_Server *server = UA_Server_new(config);

	char sMyLongString [512+1];
	memset(sMyLongString, 'a', sizeof(sMyLongString));
	sMyLongString[sizeof(sMyLongString) - 1] = 0;

	/* Define the attribute of the myString variable node */
	UA_VariableAttributes attr = UA_VariableAttributes_default;
	UA_String myString = UA_STRING(sMyLongString);
	UA_Variant_setScalar(&attr.value, &myString, &UA_TYPES[UA_TYPES_STRING]);
	attr.description = UA_LOCALIZEDTEXT("en-US", "my long string");
	attr.displayName = UA_LOCALIZEDTEXT("en-US", "my long string");
	attr.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
	attr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;

	/* Add the variable node to the information model */
	UA_NodeId myStringNodeId = UA_NODEID_STRING(1, "mylongstring");
	UA_QualifiedName myStringName = UA_QUALIFIEDNAME(1, "mylongstring");
	UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
	UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
	UA_Server_addVariableNode(server, myStringNodeId, parentNodeId,
		parentReferenceNodeId, myStringName,
		UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), attr, NULL, NULL);

    UA_StatusCode retval = UA_Server_run(server, &running);
    UA_Server_delete(server);
    UA_ServerConfig_delete(config);
    return (int)retval;
}

Server output:

[2018-06-13 09:33:27.230 (UTC+0200)] warn/session       Connection 444 | SecureChannel 1 | Session bcda5fc0-8d9d-7388-ae5a-15718ee8aeda | Subscription 2 | MonitoredItem 1 | Could not encode the value the MonitoredItem with status BadEncodingError

Client used: UaExpert

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag): 0.3-rc1-242-ga4d59260
  • Other OPC UA SDKs used (client or server):
  • Operating system: Windows, embedded
  • Logs (with UA_LOGLEVEL set as low as necessary) attached
  • Wireshark network dump attached
  • Self-contained code example attached
  • Critical issue
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