Professional OPC
Development Tools

logos

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

More
14 Sep 2017 06:58 #5513 by support
Replied by support on topic OPC UA using PHP
Can you please try the following:

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.

More
13 Sep 2017 17:31 #5512 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
I have access to Visual Studio 2017.

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.

More
13 Sep 2017 17:24 #5511 by support
Replied by support on topic OPC UA using PHP
I have now also tried the 64-bit Windows, but still was unable to reproduce the problem.

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.

More
12 Sep 2017 13:14 #5509 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
Using Windows 10 64-bit.

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.

More
09 Sep 2017 19:48 #5507 by support
Replied by support on topic OPC UA using PHP
I have tested with PHP 5.5.38, Windows 10, QuickOPC 2017.1, and so far no repro.
Are you using 32-bit or 64-bit Windows please?

Best regards

Please Log in or Create an account to join the conversation.

More
07 Sep 2017 07:33 #5499 by support
Replied by support on topic OPC UA using PHP
Many thanks. It's good that it is reproducible with our own example and server. It worked well in our testing, though. I suppose that the difference may be in the PHP version or other environmental factors (operating system), which, of course, were different.

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.

More
06 Sep 2017 15:03 #5498 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
I am still getting the following error both when running our test (local and OPCLabs server) and also via the _EasyUAClient.Read.Main.php file.

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.

More
06 Sep 2017 14:46 #5496 by support
Replied by support on topic OPC UA using PHP
Thank you. I have some additional questions:

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.

More
06 Sep 2017 13:43 #5492 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
1. We are using PHP 5.5.38, Windows 10, QuickOPC 2017.1

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.

More
06 Sep 2017 08:04 #5489 by support
Replied by support on topic OPC UA using PHP
Hello. I do not have the answer right away. Please provide some more information:

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.

Moderators: support
Time to create page: 0.076 seconds