"Timeout occurred while processing the request." on Method Call request
See original GitHub issueWhile trying to call a method on an OPC server with a custom type I always receive a “Timeout occurred while processing the request.” error. Below is the code for the request, it follows the logic you used for the method call in the IntegrationTests class.
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// describe this client application.
var clientDescription = new ApplicationDescription
{
ApplicationName = "Workstation.UaClient.FeatureTests",
ApplicationUri = $"urn:{System.Net.Dns.GetHostName()}:Workstation.UaClient.FeatureTests",
ApplicationType = ApplicationType.Client
};
var channel = new UaTcpSessionChannel(
this.localDescription,
null,
new AnonymousIdentity(),
"opc.tcp://192.168.0.254:4840",
SecurityPolicyUris.None,
loggerFactory: this.loggerFactory,
additionalTypes: new[] { typeof(ScanSettings) });
try
{
// try opening a session and reading a few nodes.
await channel.OpenAsync();
Console.WriteLine($"Opened session with endpoint '{channel.RemoteEndpoint.EndpointUrl}'.");
Console.WriteLine($"SecurityPolicy: '{channel.RemoteEndpoint.SecurityPolicyUri}'.");
Console.WriteLine($"SecurityMode: '{channel.RemoteEndpoint.SecurityMode}'.");
Console.WriteLine($"UserIdentityToken: '{channel.UserIdentity}'.");
var readRequest = new ReadRequest { NodesToRead = new[] { new ReadValueId { NodeId = NodeId.Parse("ns=4;i=6030"), AttributeId = AttributeIds.Value } } };
var readResult = await channel.ReadAsync(readRequest);
var serverStatus = readResult.Results[0].GetValueOrDefault<ServerStatusDataType>();
var set = new ScanSettings
{
Duration = 500,
Cycles = 10
};
var request = new CallRequest
{
MethodsToCall = new[] {
new CallMethodRequest
{
ObjectId = NodeId.Parse("ns=2;i=5001"),
MethodId = NodeId.Parse("ns=4;i=7010"),
InputArguments = new [] { new ExtensionObject(set)}.ToVariantArray()
}
}
};
var response = await channel.CallAsync(request);
var result = response.Results[0].OutputArguments[0].GetValueOrDefault<ScanSettings>();
Console.WriteLine($"\nClosing session '{channel.SessionId}'.");
await channel.CloseAsync();
}
catch (Exception ex)
{
await channel.AbortAsync();
Console.WriteLine(ex.Message);
}
}
[DataTypeId("ns=3;i=6044")]
[BinaryEncodingId("ns=3;i=5015")]
internal class ScanSettings : Structure
{
public uint Duration { get; set; }
public int Cycles { get; set; }
public override void Encode(IEncoder encoder)
{
encoder.WriteUInt32("Duration", this.Duration);
encoder.WriteInt32("Cycles", this.Cycles);
}
public override void Decode(IDecoder decoder)
{
this.Duration = decoder.ReadUInt32("Duration");
this.Cycles = decoder.ReadInt32("Cycles");
}
public override string ToString() => $"{{ Duration={this.Duration}; Cycles={this.Cycles}; }}";
}
Any help would be awesome. Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How To Fix the HTTP 408 Error (8 Solutions)
The 408 Request Timeout error means the request you sent to the website server took longer than the server was prepared to wait....
Read more >Preventing H12 Errors (Request Timeouts)
H12 Request Timeout errors occur when an HTTP request takes longer than 30 seconds to complete. These errors are often caused by:.
Read more >Why do I receive "The operation has timed out" when it is ...
1 Answer 1 ... The Timeout value you're setting is the amount of time for the GetResponse to respond. The HttpWebRequest also has...
Read more >Connection Timeout vs. Read Timeout for Java Sockets
When ServerSocket receives a connection request, it invokes the accept() method to instantiate a new socket object. Similarly, this method ...
Read more >Request timed out when using DataAdapter - ASP.NET
Request timed out error when you use the DataAdapter method in an ASP. ... This error occurs when the processing time exceeds 90...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try this out. I got the idea from https://reference.opcfoundation.org/v104/Core/docs/Part6/5.2.7/
Thanks everyone for the help, I managed to get a solution that used a version of what Andrew showed for the Unions that solved that one issue.
The rest of it was solved by adding a blank ReadInt32 at the beginning of the decoding, not sure why it was needed exactly, and I also had a few properties out of order from their specification. I did not realize that the property order had to be exactly as defined in the XML.