Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
java.nio.BufferUnderflowException when connecting to a OPC UA Server
February 6, 2020
18:49, EET
Avatar
HDMIKabel
Member
Members
Forum Posts: 3
Member Since:
February 6, 2020
sp_UserOfflineSmall Offline

Hello,
first off, here’s my environment:
Prosys Client Version: 4.2.0-995
Java-Version: openjdk 11.0.5 2019-10-15

I’m trying to run your SimpleClient sample. I’m doing this from my console.

This is the error output I’m getting:
log4j:WARN No appenders could be found for logger (com.prosysopc.ua.UaApplication).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4…..l#noconfig for more info.
java.nio.BufferUnderflowException
at java.base/java.nio.Buffer.nextGetIndex(Buffer.java:647)
at java.base/java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:388)
at com.prosysopc.ua.stack.utils.bytebuffer.ByteBufferReadable.getInt(SourceFile:121)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getUInt32(SourceFile:1639)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder$28.b(SourceFile:1158)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.get(SourceFile:498)
at com.prosysopc.ua.types.opcua.Serializers$StructureFieldSerializer.getEncodeable(SourceFile:8200)
at com.prosysopc.ua.StructureSerializer.getEncodeable(SourceFile:83)
at com.prosysopc.ua.stack.encoding.utils.AbstractSerializer.getEncodeable(SourceFile:155)
at com.prosysopc.ua.stack.encoding.utils.SerializerComposition.getEncodeable(SourceFile:114)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getEncodeable(SourceFile:839)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder$16.b(SourceFile:1269)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.get(SourceFile:498)
at com.prosysopc.ua.types.opcua.Serializers$StructureDefinitionSerializer.getEncodeable(SourceFile:5898)
at com.prosysopc.ua.StructureSerializer.getEncodeable(SourceFile:83)
at com.prosysopc.ua.typedictionary.StructureSpecification.getEncodeable(SourceFile:256)
at com.prosysopc.ua.stack.builtintypes.ExtensionObject.decode(SourceFile:427)
at com.prosysopc.ua.stack.builtintypes.ExtensionObject.decode(SourceFile:328)
at com.prosysopc.ua.stack.builtintypes.ExtensionObject.decode(SourceFile:287)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getExtensionObject(SourceFile:1040)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getScalarObject(SourceFile:1492)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getVariant(SourceFile:1713)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getDataValue(SourceFile:694)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder$17.b(SourceFile:1276)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.get(SourceFile:498)
at com.prosysopc.ua.types.opcua.Serializers$ReadResponseSerializer.getEncodeable(SourceFile:5586)
at com.prosysopc.ua.StructureSerializer.getEncodeable(SourceFile:83)
at com.prosysopc.ua.stack.encoding.utils.AbstractSerializer.getEncodeable(SourceFile:155)
at com.prosysopc.ua.stack.encoding.utils.SerializerComposition.getEncodeable(SourceFile:114)
at com.prosysopc.ua.stack.encoding.binary.BinaryDecoder.getMessage(SourceFile:1306)
at com.prosysopc.ua.stack.transport.tcp.io.TcpConnection$b$1.run(SourceFile:497)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Exception in thread “main” com.prosysopc.ua.ServiceException: ServiceFault [ResponseHeader=”ResponseHeader [Timestamp=”02/06/20 16:37:03.6513801 GMT”, RequestHandle=”378″, ServiceResult=”Bad_SessionIdInvalid (0x80250000) “The session id is not valid.””, ServiceDiagnostics=”Diagnostic Info:
“, StringTable=”[]”, AdditionalHeader=”null”]”] ServiceResult=Bad_SessionIdInvalid (0x80250000) “The session id is not valid.” Diagnostics=Diagnostic Info:

at com.prosysopc.ua.client.UaClient.a(SourceFile:5434)
at com.prosysopc.ua.client.UaClient.read(SourceFile:2861)
at com.prosysopc.ua.client.UaClient.readAttributes(SourceFile:3143)
at com.prosysopc.ua.client.UaClient.readAttributes(SourceFile:3110)
at com.prosysopc.ua.client.UaClient.readAttribute(SourceFile:3011)
at com.prosysopc.ua.client.UaClient.readValue(SourceFile:3285)
at com.prosysopc.ua.samples.client.SimpleClient.main(SimpleClient.java:34)
Caused by: ServiceFault [ResponseHeader=”ResponseHeader [Timestamp=”02/06/20 16:37:03.6513801 GMT”, RequestHandle=”378″, ServiceResult=”Bad_SessionIdInvalid (0x80250000) “The session id is not valid.””, ServiceDiagnostics=”Diagnostic Info:
“, StringTable=”[]”, AdditionalHeader=”null”]”]
at com.prosysopc.ua.stack.transport.impl.AsyncResultImpl.waitForResult(SourceFile:282)
at com.prosysopc.ua.stack.transport.tcp.io.SecureChannelTcp.serviceRequest(SourceFile:869)
at com.prosysopc.ua.stack.transport.tcp.io.SecureChannelTcp.serviceRequest(SourceFile:808)
at com.prosysopc.ua.stack.application.SessionChannel.serviceRequest(SourceFile:305)
at com.prosysopc.ua.stack.transport.ChannelService.Read(SourceFile:404)
at com.prosysopc.ua.client.UaClient.a(SourceFile:5428)
… 6 more

This worked with an evaluation distro of your library, namely 4.0.2-808.

Can you please help me on this one?

February 7, 2020
14:06, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Is the server you are connecting to a Siemens S7?

IF yes:
Can you download UaExpert https://www.unified-automation.com/products/development-tools/uaexpert.html?

Then using that navigate to Root/Types/DataTypes/BaseDataType/Structure/SimaticStructures/. When you click on any of your types, you should see error in the Log view (lower part of the app) with error BadEndOfStream. Also you cannot see any of that Nodes Attributes, the Attributes view is not updating, it just shows the SimaticStructures node (assuming you clicked that before trying anything below). If this happens I would conclude that it is Siemens’ problem and you should report it to them. If some node works, please check them all in that case if any is to give that error.

The fixes and changes of 4.2.0 will make it to try to read the new 1.04 Attributes, one of them is DataTypeDefinition. We read these on connection (we are aware of a perf problem here on servers with lots of Structures; will be fixed). It provides meta-info how Structures are encoded/decoded. It will replace so called DataTypeDictionaries at some point so we need to start prioritize DataTypeDefinitions over DataTypeDictionaries. If server doesn’t support the new Attributes, it should just return a bad statuscode. However the Siemens’ impl actually returns non-valid data (I have not yet analyzed the raw binary too much; will do at some point if really needed), basically it is as-if it appears to start correctly, but it is not valid binary form (too less or too little), thus SDK fails to read them. The connection itself should eventually work (but it might take like minutes due to timeouts in the reads).

If this is urgent, we might need to build a flag to disable DataTypeDefinition reading, however that might get sort of complicated and anyway server’s should either report a bad statuscode of not supporting the attribute and/or return valid data.

IF no, well I’m quite sure it is the “yes” case (as that “at com.prosysopc.ua.types.opcua.Serializers$StructureDefinitionSerializer.getEncodeable(SourceFile:5898)” is for the DataTypeDefinition) , and/or you can check it with UaExpert anyway the same way (any type below “Structure” type)

February 7, 2020
14:08, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Also if it was S7, you could try to update it’s firmware to see if Siemens has fixed this already, wasn’t the last time we checked in our test device few days ago.

February 11, 2020
12:02, EET
Avatar
HDMIKabel
Member
Members
Forum Posts: 3
Member Since:
February 6, 2020
sp_UserOfflineSmall Offline

Hello,

thanks for your reply. Unfortunately we do not have direct control over the server. We can ask the admin to update the firmware as you suggested, but I’m not sure how long that will take. In the meantime, we have downgraded to 4.14 and it works, for the moment.

If it’s any help to you, here are some of the server’s specs:
ManufacturerName: SIEMENS AG
ProductName: SIMATIC S7-1500 OPC UA
SoftwareVersion: V02.05.02

I can’t help but wonder: Shouldn’t the SDK be able to handle invalid responses from OPC UA servers? I get that the OPC UA Specifiaction exists and that it should be implemented by everyone to the T, but in my experience, this is pretty often not the case.

Anyways, this isn’t really urgent, the downgrade works as a temporary solution. However, we really want to use the newest version of the ProSYS SDK, so I would appreciate it if there was some fix for this in your pipeline. We’ll try and get the admin to upgrade the software, too.

Thanks for your help!

February 11, 2020
13:08, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

In a perfect world we should be able to handle anything, but generally if the binary protocol itself is violated, then it is not so simple. And it should be noted that in our current tests UaExpert was not either able to deal with this, i.e. trying to show the DataType’s Attributes where the errorneus DataTypeDefinion Attribute data is resulted in the BadEndOfStream and black screen. But yes, we should probably deal this better somehow, i.e. UaExpert is still a lot better. Anyway in this case the server does not respond e.g. with Bad_AttributeIdInvalid “The attribute is not supported for the specified Node.”, but instead returns a properly starting binary form, but it is for some reason not as big as the form specifies it to be, thus the error.

Anyway, some way to deal with this will be added to the next version and I can once again give beta links before that if needed. Still better would be if you can report this to Siemens so that they would eventually fix their server.

January 4, 2021
17:49, EET
Avatar
msaala
Member
Members
Forum Posts: 3
Member Since:
November 16, 2015
sp_UserOfflineSmall Offline

Hello,

it looks like we have the same problem with a SIEMES S7. We get the same stack trace when establishing a connection. We are using the current version SDK version 4.5 – is it possible that there is no workaround for the problem yet? The root of the evil is probably the Siemens PLC, but we often have no influence on the software used there.
BR Michael

January 5, 2021
9:32, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Please try to disable the usage of the 1.04 attributes with

UaClient.getAddressSpace().setRead104Attributes(false)
Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 735

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1523

Posts: 6449

Newest Members:

rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1