read/write of arrays / server drops connection after ~30 read/write actions

448 views
Skip to first unread message

Armin

unread,
Jun 30, 2015, 3:36:45 AM6/30/15
to open...@googlegroups.com


Hallo,

I'm trying to use open62541 for our CFC tool and have two problems.

When I try to update the data of an array with one dimension, I have to provide the the size of the dimension within the write request. Without providing it, the configuration of the array node will be corrupted at server site.

I have change the example client in order to do the read/write actions for an integer node in an endless loop. The R/W actions are running only round about 30 times until the server drops the connection. The same game after stopping and starting the client.

Below is a subset of the print outs of the test.  What could be the reason for dropping the connection ?  ( I'm using the original client and server example ... )
 
Writing a value of node (1, "the.answer"):
the new value is: 253

Reading the value of node (1, "the.answer"):
the value is: 253

Writing a value of node (1, "the.answer"):
the new value is: 254

Reading the value of node (1, "the.answer"):
the service result is: 80ae0000

Writing a value of node (1, "the.answer"):

Reading the value of node (1, "the.answer"):
the service result is: 80ae0000

Writing a value of node (1, "the.answer"):

Reading the value of node (1, "the.answer"):
the service result is: 80ae0000

Writing a value of node (1, "the.answer"):
^C

Best Regards

Armin

f.palm

unread,
Jun 30, 2015, 5:22:14 AM6/30/15
to open...@googlegroups.com, sjaste...@gmail.com
Hello Armin,
to 1) I couldn't reproduce your issue. With update you mean a simple write request, don't you? In which way is the server node corrupted?
I have put this code into the client to modify the demo node ns=1, id=51012 (Int32 Array):
----------------------
    // Write node's value
    printf("\nWriting a value of node (51012, \"Int32 Array \"):\n");
    UA_WriteRequest wReq;
    UA_WriteRequest_init(&wReq);
    wReq.nodesToWrite = UA_WriteValue_new();
    wReq.nodesToWriteSize = 1;

    UA_Int32 *myInt32Array = UA_Array_new(&UA_TYPES[UA_TYPES_INT32],10);
    for(UA_Int32 i=0;i<10;i++){
        myInt32Array[i]=i;
    }
    wReq.nodesToWrite[0].nodeId.namespaceIndex = 1;
    wReq.nodesToWrite[0].nodeId.identifierType = UA_NODEIDTYPE_NUMERIC;
    wReq.nodesToWrite[0].nodeId.identifier.numeric = 51012;
    wReq.nodesToWrite[0].attributeId = UA_ATTRIBUTEID_VALUE;
    wReq.nodesToWrite[0].value.hasValue = UA_TRUE;
    wReq.nodesToWrite[0].value.value.arrayLength = 10;
    wReq.nodesToWrite[0].value.value.type = &UA_TYPES[UA_TYPES_INT32];
    wReq.nodesToWrite[0].value.value.storageType = UA_VARIANT_DATA_NODELETE; //do not free the integer on deletion
    wReq.nodesToWrite[0].value.value.data = myInt32Array;

    UA_WriteResponse wResp = UA_Client_write(client, &wReq);
    if(wResp.responseHeader.serviceResult == UA_STATUSCODE_GOOD)
            printf("write array was successful \n");
    UA_WriteRequest_deleteMembers(&wReq);
    UA_WriteResponse_deleteMembers(&wResp);
    UA_Array_delete(myInt32Array,&UA_TYPES[UA_TYPES_INT32],10);
--------------------
worked well so far.

to 2) I could not reproduce this issue either. Could you please post the code of the loop which calls the write-service. In my test case I wrote the "the answer" node 500 times.

Best Regards
Florian

Armin

unread,
Jun 30, 2015, 10:33:59 AM6/30/15
to open...@googlegroups.com, sjaste...@gmail.com
Hallo Florian,

   wReq.nodesToWrite[0].nodeId.
namespaceIndex = 1;
    wReq.nodesToWrite[0].nodeId.identifierType = UA_NODEIDTYPE_NUMERIC;
    wReq.nodesToWrite[0].nodeId.identifier.numeric = 51012;
    wReq.nodesToWrite[0].attributeId = UA_ATTRIBUTEID_VALUE;
    wReq.nodesToWrite[0].value.hasValue = UA_TRUE;
    wReq.nodesToWrite[0].value.value.arrayLength = 10;

When I set the arrayLength = -1 in the write request, the next read request doesn't find an array ... only an Int32.
 
Below ist the client loop ... what means the MAXSESSIONLIFETIME ?
    // Read node's value
    for(;;)
    {
    printf("\nReading the value of node (1, \"the.answer\"):\n");
    UA_ReadRequest rReq;
    UA_ReadRequest_init(&rReq);
    rReq.nodesToRead = UA_ReadValueId_new();
    rReq.nodesToReadSize = 1;
    rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer"); /* assume this node exists */
    rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;

    UA_ReadResponse rResp = UA_Client_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_INT32]) {
        value = *(UA_Int32*)rResp.results[0].value.data;
        printf("the value is: %i\n", value);
    }
    else
    {
      printf("the service result is: %08x\n", rResp.responseHeader.serviceResult);     
    }

    UA_ReadRequest_deleteMembers(&rReq);
    UA_ReadResponse_deleteMembers(&rResp);

    value++;

    // Write node's value
    printf("\nWriting a value of node (1, \"the.answer\"):\n");

    UA_WriteRequest wReq;
    UA_WriteRequest_init(&wReq);
    wReq.nodesToWrite = UA_WriteValue_new();
    wReq.nodesToWriteSize = 1;
    wReq.nodesToWrite[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer"); /* assume this node exists */

    wReq.nodesToWrite[0].attributeId = UA_ATTRIBUTEID_VALUE;
    wReq.nodesToWrite[0].value.hasValue = UA_TRUE;
    wReq.nodesToWrite[0].value.value.type = &UA_TYPES[UA_TYPES_INT32];
    wReq.nodesToWrite[0].value.value.storageType = UA_VARIANT_DATA_NODELETE; //do not free the integer on deletion
    wReq.nodesToWrite[0].value.value.data = &value;


    UA_WriteResponse wResp = UA_Client_write(client, &wReq);
    if(wResp.responseHeader.serviceResult == UA_STATUSCODE_GOOD)
            printf("the new value is: %i\n", value);

    UA_WriteRequest_deleteMembers(&wReq);
    UA_WriteResponse_deleteMembers(&wResp);
   
    sleep(1);
    }

Best Regards

Armin



sjaste...@gmail.com

unread,
Jul 3, 2015, 10:28:45 AM7/3/15
to open...@googlegroups.com, sjaste...@gmail.com

Hi Florian,

I'm running now the server as 32bit app on SuSE 13.1 / 64bit.

The dropping of the connection happens now after the message "The message was not entirely processed, skipping to the end" from the server. Please see below:


Reading the value of node (1, "the.answer"):
the value is: 143


Writing a value of node (1, "the.answer"):
the new value is: 144


Reading the value of node (1, "the.answer"):
[07/03/2015 13:25:25.836.255] info/communication        The message was not entirely processed, skipping to the end  -->>  message from the server

the service result is: 80ae0000  -->> what the client returns.


Writing a value of node (1, "the.answer"):

However,  this is a real show stopper!  Where to look to find the problem ?
The update of an array node is just a small design problem(?) ....


Best Regards

Armin

f.palm

unread,
Jul 3, 2015, 10:59:42 AM7/3/15
to open...@googlegroups.com, sjaste...@gmail.com
Hi Armin,

Could you sniff the communication with wireshark and send me the dump? Right now, I have no clue why the server stops working. ( I assume that you have checked out the latest version from github)

The fact that you have to set the actual size of the array which you want to update is because the client "API" is kind of raw. A nice encapsulation of it is something which needs to be done in future.

Best regards
Florian

sjaste...@gmail.com

unread,
Jul 3, 2015, 11:43:37 AM7/3/15
to open...@googlegroups.com, sjaste...@gmail.com

Hi Florian,


>Could you sniff the communication with wireshark and send me the dump? Right now, I have no clue why the server stops working.

It seems to be a timing issue. After removing the sleep statement, it is possible to submit 262942 read/write request. But it stops exactly after 32.5 seconds :)


Reading the value of node (1, "the.answer"):
the value is: 262984


Writing a value of node (1, "the.answer"):
the new value is: 262985


Reading the value of node (1, "the.answer"):
the service result is: 80ae0000

However I will come back with a wireshark trace ...



( I assume that you have checked out the latest version from github)

yes I did


>The fact that you have to set the actual size of the array which you want to update is because the client "API" is kind of raw. A nice encapsulation of it is something which needs to be done in future.

OK ... it's just a nitty gritty detail :)

Thanks so far

Armin

Julius Pfrommer

unread,
Jul 4, 2015, 3:52:49 AM7/4/15
to open...@googlegroups.com, sjaste...@gmail.com, sjaste...@gmail.com
Hi Armin,

I was able to reproduce you problem with the 0.1 release.
When we released 0.1, we were focused very on getting the server right. The client didn't get much polish.

For example, the client does not automatically extend the lifetime of its session. That needs to be done automatically.

However, things improved quite a bit since then.
If you just drop in the open62541.c / .h generated from the current master, your problems will just magically go away. :-)
Here's the link: http://open62541.org/releases/0b9b7095ca.zip

There are also some convenience functions for handling scalars and arrays in variants.

UA_Boolean UA_Variant_isScalar(const UA_Variant *v);
UA_StatusCode UA_Variant_setScalar(UA_Variant *v, void *p, const UA_DataType *type);
UA_StatusCode UA_Variant_setScalarCopy(UA_Variant *v, const void *p, const UA_DataType *type);
UA_StatusCode UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32 elements, const UA_DataType *type);
UA_StatusCode UA_Variant_setArrayCopy(UA_Variant *v, const void *array, UA_Int32 elements, const UA_DataType *type);

Best regards
Julius
Message has been deleted

sjaste...@gmail.com

unread,
Jul 6, 2015, 9:53:13 AM7/6/15
to open...@googlegroups.com, sjaste...@gmail.com
Hi Julius,

Am Samstag, 4. Juli 2015 09:52:49 UTC+2 schrieb Julius Pfrommer:
Hi Armin,

I was able to reproduce you problem with the 0.1 release.
When we released 0.1, we were focused very on getting the server right. The client didn't get much polish.

For example, the client does not automatically extend the lifetime of its session. That needs to be done automatically.

However, things improved quite a bit since then.
If you just drop in the open62541.c / .h generated from the current master, your problems will just magically go away. :-)

Thanks a lot !!
 
I'm not using the amalgamated version, because I have to link against a library.

Is the current open62541-master.zip version equivalent ?

Best Regards

Armin
 

sjaste...@gmail.com

unread,
Jul 7, 2015, 6:50:39 AM7/7/15
to open...@googlegroups.com, sjaste...@gmail.com
Hi Julius,

all is working with the current clone. Thank you !

Armin
Reply all
Reply to author
Forward
0 new messages