Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
OPC UA using PHP
1. Make it possible to attach the Visual Studio debugger to the PHP process before the error occurs. This can be don e.g. by adding a "sleep" (wait) to the beginning of the PHP script, for the time necessary to attached the debugger - e.g. 30 seconds.
2. Start Visual Studio, and in Debug -> Windows -> Exception Settings, click on "Common Language Runtime Exception", and then type System.ArgumentException into the Search box. Check the box next to the exception name when it appears.
3. Start your PHP script in PHP.EXE process.
4. (now you only have 30 seconds or whatever time you put into the wait command to do this step) In Visual Studio, select Debug -> Attach to Process. Press the "Select" button next to "Attach to:", and select "Debug these code types", and make sure that "Managed (v4.6, v4.5, v4.0)" is checked; then press OK to close the "Select Code Type" dialog. In the list of Available processes, find your php.exe, select it, and then press the "Attach" button.
5. Hopefully, when the PHP script continues and the error occurs, Visual Studio will catch the exception at the moment it is thrown, and break into the debugger. If so, please obtain all details of the exception and send them to us. Most importantly, we need the call stack at the place it has occurred.
Thank you
Please Log in or Create an account to join the conversation.
FWIW, I am also able to reproduce the issue on Windows Server 2012 64-bit.
Please Log in or Create an account to join the conversation.
Do you have access to Visual Studio? If so, I would put together instructions on how to (hopefully) catch the exception right when it is thrown, together with the stack trace, which could point me to the cause of the issue.
Regards
Please Log in or Create an account to join the conversation.
In order to check the error response, I need to add a try/catch to the php code. Otherwise the script stops at the $Client->Read line.
<?php
// $Header: $
// Copyright [c] CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
//#region Example
// This example shows how to read and display data of an attribute (value, timestamps, and status code).
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
// Obtain attribute data. By default, the Value attribute of a node will be read.
try{
$AttributeData = $Client->Read(
"http://opcua.demo-this.com:51211/UA/SampleServer",
"nsu=http://test.org/UA/Data/;i=10853"); // or "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
}
catch(Exception $e){
printf($e);
}
// Display results
printf("Value: %s\n", $AttributeData->Value);
printf("ServerTimestamp: %s\n", $AttributeData->ServerTimestamp);
printf("SourceTimestamp: %s\n", $AttributeData->SourceTimestamp);
printf("StatusCode: %s\n", $AttributeData->StatusCode);
// Example output:
//
//Value: -2.230064E-31
//ServerTimestamp: 11/6/2011 1:34:30 PM
//SourceTimestamp: 11/6/2011 1:34:30 PM
//StatusCode: Good
//#endregion Example
?>
Please Log in or Create an account to join the conversation.
Are you using 32-bit or 64-bit Windows please?
Best regards
Please Log in or Create an account to join the conversation.
We will try to reproduce it with the PHP version you are using. Please allow some time. I will reply here when I have an update.
Best regards
Please Log in or Create an account to join the conversation.
C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples>php _EasyUAClient.Read.Main.php
PHP Fatal error: Uncaught exception 'com_exception' with message 'Source: mscorlib
Description: Length cannot be less than zero.
Parameter name: length' in C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples\_EasyUAClient.Read.Main.php:13
Stack trace:
#0 C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples\_EasyUAClient.Read.Main.php(13): com->Read('http://opcua.de...', 'nsu=http://test...')
#1 {main}
thrown in C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples\_EasyUAClient.Read.Main.php on line 13
When run via web browser, we have the following response:
Value: 1.9620245196987E-28 ServerTimestamp: 9/6/2017 3:01:10 PM SourceTimestamp: 9/6/2017 3:01:10 PM StatusCode: Good
Please Log in or Create an account to join the conversation.
1. Can you please try the same using our public demo server (the one that is addressed in our examples, on opcua.demo-this.com)? I am trying to determine whether the problem is server-dependendent.
2. Can you please replace the ReadValue with just Read? I am trying to determine whether the error has to do with status of the returned attribute data (the Read method returns an object that contains the data even in case of bad status).
3. QuickOPC comes with a bunch of console based PHP examples. Under the COM examples, they are in PHP/Console/UADocExamples. When you run the examples (e.g. the _EasyUAClient.Read.Main.php), does it work?
Regards
Please Log in or Create an account to join the conversation.
2. PHP throws the following exception for OPC UA polling run via CLI, but works fine and throws no exception when run via web browser, or php-win.
exception 'com_exception' with message 'Source: mscorlib
Description: Length cannot be less than zero.
Parameter name: length' in C:\Websites\das\php\update.php:2041
Stack trace:
#0 C:\Websites\das\php\update.php(2041): com->ReadValue('opc.tcp://127.0...', 'ns=5;s=Counter1')
#1 C:\Websites\das\php\update.php(200): ua_read(Object(com), 'opc.tcp://127.0...', 'ns=5;s=Counter1')
#2 C:\Websites\das\php\update.php(26): data_instant()
#3 {main}
Please Log in or Create an account to join the conversation.
1. Which PHP version are you using?
2. What are the precise symptoms (what do you mean by "does not work"). Error messages, exceptions, etc. - as much info as possible.
I do not think this is related to UAC. Also, QuickOPC itself does neither require nor set any environment variables (if the particular hosting environment such as PHP requires it, it is up to the user to set them up).
Best regards
Please Log in or Create an account to join the conversation.