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

No return value from server-method and status code *uncertain* #6437

Open
augustinust opened this issue Apr 23, 2024 · 4 comments
Open

No return value from server-method and status code *uncertain* #6437

augustinust opened this issue Apr 23, 2024 · 4 comments

Comments

@augustinust
Copy link

Description

I have a simple server with some methods. If a method fails(not completely), I want to provide
some more information beside the status code to the client.

When I use UA_STATUSCODE_UNCERTAIN as method return code, nothing (except the status code)
is returned to the client.

Is this behaviour correct?

If so, what is the "correct" way to indicate something went wrong executing the method?

I thought of returning a UA_Variant with

  • status code
  • the explanation in case of a failure

Checklist

Please provide the following information:

  • [ x] open62541 Version (release number or git tag): 1.3
  • [ x] Operating system: Debian 12
@augustinust
Copy link
Author

update

I started a open62541-server with a method returning uncertain.
Then I called the method with UaExpert - and I get a result.

But with the open62541-client code, the result is empty.

@augustinust
Copy link
Author

I fixed the issue locally by editing the method UA_Client_call in the file ua_client_highlevel.c.

Original:

    if(retval == UA_STATUSCODE_GOOD) {
        if(response.resultsSize == 1)
            retval = response.results[0].statusCode;
        else
            retval = UA_STATUSCODE_BADUNEXPECTEDERROR;
    }
    if(retval != UA_STATUSCODE_GOOD) {
        UA_CallResponse_clear(&response);
        return retval;
    }

Slightly modified version:

    if(retval == UA_STATUSCODE_GOOD || retval == UA_STATUSCODE_UNCERTAIN) {
        if(response.resultsSize == 1)
            retval = response.results[0].statusCode;
        else
            retval = UA_STATUSCODE_BADUNEXPECTEDERROR;
    } else {
        UA_CallResponse_clear(&response);
        return retval;
    }

@tboeckel
Copy link

I also encountered the problem that none of the output parameters are returned to the calling client if a method returns a different status code than UA_STATUSCODE_GOOD.
Therefore all methods of my servers always return the status code UA_STATUSCODE_GOOD, because calling the method from an OPC-UA point of view was successful.
Additionally all methods always have at least two output parameters (success:bool and message:string). If everything went alright, then success=true and message="ok" will be returned, otherwise success=false and message="whatever went wrong" will be returned. That way it is easy to check wether the method call was successful at all and to return arbitrarily verbose informations about possible failures.

@augustinust
Copy link
Author

The server sends values when the status code is uncertain, but the open62541-client does not return them.
When I use another client(UaExpert, node-opcua), I get a result.

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

2 participants