Comments (10)
Thanks for question.
The InputArguments need to be an empty array to be encoded correctly.
func ExampleClient_Call() {
ctx := context.Background()
// open a connection to testserver running locally. Testserver is started if not already running.
ch, err := client.Dial(
ctx,
"opc.tcp://localhost:48010",
client.WithClientCertificatePaths("./pki/client.crt", "./pki/client.key"), // need secure channel to send password
client.WithUserNameIdentity("root", "secret"), // need role of "operator" to call this method
client.WithInsecureSkipVerify(), // skips verification of server certificate
)
if err != nil {
fmt.Printf("Error opening client connection. %s\n", err.Error())
return
}
// prepare call request
req := &ua.CallRequest{
MethodsToCall: []ua.CallMethodRequest{
{
ObjectID: ua.ObjectIDServerConfiguration,
MethodID: ua.MethodIDServerConfigurationApplyChanges,
InputArguments: []ua.Variant{},
},
},
}
// send request to server. receive response or error
res, err := ch.Call(ctx, req)
if err != nil {
fmt.Printf("Error calling method. %s\n", err.Error())
ch.Abort(ctx)
return
}
// print results
fmt.Printf("Call method result:\n")
fmt.Println(res.Results[0].StatusCode)
// close connection
err = ch.Close(ctx)
if err != nil {
ch.Abort(ctx)
return
}
// Output:
// Call method result:
// The operation completed successfully.
}
from opcua.
Hi Andrew,
Many thanks for the quick reply. Although I'm fairly certain I tried it that way already, I'll double check on Monday and will post the results here.
from opcua.
Hi Andrew,
Unfortunately, the example does not yield any different results from what I've seen before. Let me try to illustrate what's currently happening and what is expected.
Current situation:
The Siemens PLC is in provisioning mode and all method calls to open, write, close and update the trustlists works as expected. As does creating a singing request and consequently updating the certificates. Only ApplyChanges is not showing the expected behaviour as seen in TIA Portal:
which overlaps with the trace of the method call:
2024/06/03 08:18:33 CallRequest{
"AuthenticationToken": "i=2470488320",
"Timestamp": "2024-06-03T08:18:33.9970046+02:00",
"RequestHandle": 5,
"ReturnDiagnostics": 0,
"AuditEntryID": "",
"TimeoutHint": 15000,
"AdditionalHeader": null,
"MethodsToCall": [
{
"ObjectID": "i=12637",
"MethodID": "i=12740",
"InputArguments": []
}
]
}
2024/06/03 08:18:34 CallResponse{
"Timestamp": "2024-06-03T06:18:38.8290046Z",
"RequestHandle": 5,
"ServiceResult": 0,
"ServiceDiagnostics": {},
"StringTable": null,
"AdditionalHeader": null,
"Results": [
{
"StatusCode": 0,
"InputArgumentResults": null,
"InputArgumentDiagnosticInfos": null,
"OutputArguments": null
}
],
"DiagnosticInfos": null
}
However, when the method call is executed through UA Expert (or python for that matter), the method call is actually executed and the Diagnostics buffer indicates that provisioning has been successful:
So even though the operation is completed successfully, something seems to be going wrong.
Again, any help would be greatly appreciated and if I can provide any additional information to better understand the problem I would be happy to do so.
from opcua.
Is it possible you are connecting with different security mode or user identity?
Also, I have a S7-1500. I don't see the ServerConfiguration node. I'll have to do some reading :(
from opcua.
Hi Andrew,
I've just created a pull request with some GDS push example code. A connected PLC should be in provisioning mode, which can be achieved after following section 2.3 in this Siemens guide:
https://cache.industry.siemens.com/dl/files/888/109799888/att_1082229/v4/109799888_OPCUA_GDSPush_DOC_V1.0_en.pdf
The endpointURL and UserNameIdentitiy should probably be modified in cmd/testGDSPush/main.go, but all required certificates should generate automatically.
A hint on where the issue might originate from is that the method call returns BadInvalidState when executed from the example code. However, this should not be the case. The fact that the method can be successfully called from UA Expert and Python after OpenWriteCloseAndUpdate() demonstrates that the function call should execute successfully using Go too.
Let me know if this is of any help!
from opcua.
Related Issues (20)
- Question: Attribute not supported when reading description of an object HOT 13
- Server stops replying to OpenSecureChannelRequest HOT 3
- Get session info from srv HOT 3
- CTT OPC UA fondation HOT 5
- in WithX509Identity it 'll be nice to load cert/key through path HOT 2
- We can't acces response of OpenSecureChannel/CreateSession/ActivateSession with DIAL HOT 1
- Dial return BadUnexpectedError rather than Bad_SecurityModeRejected when no security mode when ther is no match HOT 1
- Arbitrary Extension Objects HOT 1
- panic: runtime error: slice bounds out of range [:1414012975] with capacity 65536
- Question regarding message size HOT 7
- Can't connect to OPCUA server with certs generated by AC HOT 3
- Question: Writing struct HOT 3
- panic: send on closed channel HOT 2
- PLC behind router/vpn HOT 3
- Possibility to modify defaultMaxMessageSize HOT 3
- fatal error: checkptr: pointer arithmetic result points to invalid allocation HOT 2
- opcua server HOT 1
- Opcua server authentication issue HOT 1
- [HELP] custom dataType can not be loaded HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opcua.