Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-register-server-sessionless #1193

Merged

Conversation

AndreasHeine
Copy link
Member

Spec. Reference: https://reference.opcfoundation.org/Core/Part4/v104/docs/5.4.5

A Servershall establish a SecureChannelwith the Discovery Serverbefore calling this Service. The SecureChannelis described in 5.5. The Administratorof the Servershall provide the Serverwith an EndpointDescriptionfor the Discovery Server as part of the configuration process. Discovery Serversshall reject registrations if the serverUriprovided does not match the applicationUriin Server Certificateused to create the SecureChannel.

the spec. does not say anything about creating a session!
we probalby need to rework ua_processor to process a register/register2 without a session!

@AndreasHeine AndreasHeine requested a review from oroulet February 4, 2023 16:50
@AndreasHeine AndreasHeine added the bug Something isn't working label Feb 4, 2023
@AndreasHeine
Copy link
Member Author

testing against 3rd party LDS -> e.g. Node-Opcua [tested and approved] and OPC-F LDS [open but confident ;)]

@AndreasHeine AndreasHeine marked this pull request as ready for review February 5, 2023 21:47
@AndreasHeine
Copy link
Member Author

ping @oroulet

@AndreasHeine
Copy link
Member Author

AndreasHeine commented Feb 6, 2023

somehow with opc-ua-local-discovery-server-1.04.405.481-20221107 its not able to register...

DEBUG:asyncua.server.server:OPC UA Server(opc.tcp://0.0.0.0:4845/freeopcua/server/) server started
INFO:asyncua.client.client:connect
INFO:asyncua.client.ua_client.UaClient:opening connection
DEBUG:asyncio:Get address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1> took 16.000ms: [(<AddressFamily.AF_INET6: 23>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('::1', 4840, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('127.0.0.1', 4840))]
DEBUG:asyncio:<asyncio.TransportSocket fd=568, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 16474, 0, 0), raddr=('::1', 4840, 0, 0)> connected to localhost:4840: (<_ProactorSocketTransport fd=568 read=<_OverlappedFuture pending overlapped=<pending, 0x1cdf85efee0> cb=[_ProactorReadPipeTransport._loop_reading()] created at C:\Python39\lib\asyncio\windows_events.py:465>>, <asyncua.client.ua_client.UASocketProtocol object at 0x000001CDF4803A60>)
INFO:asyncua.uaprotocol:updating client limits to: TransportLimits(max_recv_buffer=65536, max_send_buffer=65536, max_chunk_count=0, max_message_size=16777216)
INFO:asyncua.client.ua_client.UASocketProtocol:open_secure_channel
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: OpenSecureChannelRequest(TypeId=FourByteNodeId(Identifier=446, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 12, 57, 47, 839992), RequestHandle=1, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=1000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Parameters=OpenSecureChannelParameters(ClientProtocolVersion=0, RequestType=<SecurityTokenRequestType.Issue: 0>, SecurityMode=<MessageSecurityMode.None_: 1>, ClientNonce=b'', RequestedLifetime=3600000))
DEBUG:asyncua.client.ua_client.UaClient:register_server
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: RegisterServerRequest(TypeId=FourByteNodeId(Identifier=437, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 12, 57, 47, 853360), RequestHandle=2, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=4000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Server=RegisteredServer(ServerUri='urn:freeopcua:python:server', ProductUri='urn:freeopcua.github.io:python:server', ServerNames=[LocalizedText(Locale=None, Text='FreeOpcUa Python Server')], ServerType=<ApplicationType.ClientAndServer: 2>, GatewayServerUri=None, DiscoveryUrls=['opc.tcp://0.0.0.0:4845/freeopcua/server/'], SemaphoreFilePath=None, IsOnline=True))
WARNING:asyncua.uaprotocol:Received an error: ErrorMessage(Error=StatusCode(value=2148204544), Reason=None)
CRITICAL:asyncua.client.ua_client.UASocketProtocol:Received an error: ErrorMessage(Error=StatusCode(value=2148204544), Reason=None)
INFO:asyncua.client.ua_client.UASocketProtocol:Request to close socket received
INFO:asyncua.client.ua_client.UASocketProtocol:Socket has closed connection
INFO:asyncua.client.client:disconnect

With node-opcua lds:

DEBUG:asyncua.server.server:OPC UA Server(opc.tcp://0.0.0.0:4845/freeopcua/server/) server started
INFO:asyncua.client.client:connect
INFO:asyncua.client.ua_client.UaClient:opening connection
DEBUG:asyncio:Get address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1> took 16.000ms: [(<AddressFamily.AF_INET6: 23>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('::1', 4840, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('127.0.0.1', 4840))]
DEBUG:asyncio:<asyncio.TransportSocket fd=824, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 16562), raddr=('127.0.0.1', 4840)> 
connected to localhost:4840: (<_ProactorSocketTransport fd=824 read=<_OverlappedFuture pending overlapped=<pending, 0x1de533aeca0> cb=[_ProactorReadPipeTransport._loop_reading()] created at C:\Python39\lib\asyncio\windows_events.py:465>>, <asyncua.client.ua_client.UASocketProtocol object at 0x000001DE4F5C3A60>)
INFO:asyncua.uaprotocol:updating client limits to: TransportLimits(max_recv_buffer=524288, max_send_buffer=524288, max_chunk_count=32, max_message_size=16777216)
INFO:asyncua.client.ua_client.UASocketProtocol:open_secure_channel
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: OpenSecureChannelRequest(TypeId=FourByteNodeId(Identifier=446, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 532759), RequestHandle=1, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=1000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Parameters=OpenSecureChannelParameters(ClientProtocolVersion=0, RequestType=<SecurityTokenRequestType.Issue: 0>, SecurityMode=<MessageSecurityMode.None_: 1>, ClientNonce=b'', RequestedLifetime=3600000))
INFO:asyncua.client.client:Requested secure channel timeout to be 3600000ms, got 600000ms instead
DEBUG:asyncua.client.ua_client.UaClient:register_server
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: RegisterServerRequest(TypeId=FourByteNodeId(Identifier=437, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 581855), RequestHandle=2, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=4000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Server=RegisteredServer(ServerUri='urn:freeopcua:python:server', ProductUri='urn:freeopcua.github.io:python:server', ServerNames=[LocalizedText(Locale=None, Text='FreeOpcUa Python Server')], ServerType=<ApplicationType.ClientAndServer: 2>, GatewayServerUri=None, DiscoveryUrls=['opc.tcp://0.0.0.0:4845/freeopcua/server/'], SemaphoreFilePath=None, IsOnline=True))
DEBUG:asyncua.client.ua_client.UaClient:RegisterServerResponse(TypeId=NodeId(Identifier=440, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), ResponseHeader_=ResponseHeader(Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 660000), RequestHandle=2, ServiceResult=StatusCode(value=0), ServiceDiagnostics=DiagnosticInfo(SymbolicId=None, NamespaceURI=None, Locale=None, LocalizedText=None, AdditionalInfo=None, InnerStatusCode=None, InnerDiagnosticInfo=None), StringTable=[], AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)))
INFO:asyncua.client.client:disconnect
INFO:asyncua.client.ua_client.UASocketProtocol:close_secure_channel
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: CloseSecureChannelRequest(TypeId=FourByteNodeId(Identifier=452, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 673423), RequestHandle=3, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=1000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)))
INFO:asyncua.client.ua_client.UASocketProtocol:Request to close socket received
INFO:asyncua.client.ua_client.UASocketProtocol:Socket has closed connection
INFO:asyncua.client.client:connect
INFO:asyncua.client.ua_client.UaClient:opening connection
DEBUG:asyncio:Get address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:4840, type=<SocketKind.SOCK_STREAM: 1> took 0.000ms: [(<AddressFamily.AF_INET6: 23>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('::1', 4840, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('127.0.0.1', 4840))]
DEBUG:asyncio:<asyncio.TransportSocket fd=896, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 16563, 0, 0), raddr=('::1', 4840, 0, 0)> connected to localhost:4840: (<_ProactorSocketTransport fd=896 read=<_OverlappedFuture pending overlapped=<pending, 0x1de533e4790> cb=[_ProactorReadPipeTransport._loop_reading()] created at C:\Python39\lib\asyncio\windows_events.py:465>>, <asyncua.client.ua_client.UASocketProtocol object at 0x000001DE4EB89EE0>)
INFO:asyncua.uaprotocol:updating client limits to: TransportLimits(max_recv_buffer=524288, max_send_buffer=524288, max_chunk_count=32, max_message_size=16777216)
INFO:asyncua.client.ua_client.UASocketProtocol:open_secure_channel
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: OpenSecureChannelRequest(TypeId=FourByteNodeId(Identifier=446, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 800399), RequestHandle=1, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=1000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Parameters=OpenSecureChannelParameters(ClientProtocolVersion=0, RequestType=<SecurityTokenRequestType.Issue: 0>, SecurityMode=<MessageSecurityMode.None_: 1>, ClientNonce=b'', RequestedLifetime=600000))
DEBUG:asyncua.client.ua_client.UaClient:register_server
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: RegisterServerRequest(TypeId=FourByteNodeId(Identifier=437, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 833381), RequestHandle=2, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=4000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)), Server=RegisteredServer(ServerUri='urn:freeopcua:python:server', ProductUri='urn:freeopcua.github.io:python:server', ServerNames=[LocalizedText(Locale=None, Text='FreeOpcUa Python Server')], ServerType=<ApplicationType.ClientAndServer: 2>, GatewayServerUri=None, DiscoveryUrls=['opc.tcp://0.0.0.0:4845/freeopcua/server/'], SemaphoreFilePath=None, IsOnline=True))
DEBUG:asyncua.client.ua_client.UaClient:RegisterServerResponse(TypeId=NodeId(Identifier=440, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), ResponseHeader_=ResponseHeader(Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 850000), RequestHandle=2, ServiceResult=StatusCode(value=0), ServiceDiagnostics=DiagnosticInfo(SymbolicId=None, NamespaceURI=None, Locale=None, LocalizedText=None, AdditionalInfo=None, InnerStatusCode=None, InnerDiagnosticInfo=None), StringTable=[], AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)))
INFO:asyncua.client.client:disconnect
INFO:asyncua.client.ua_client.UASocketProtocol:close_secure_channel
DEBUG:asyncua.client.ua_client.UASocketProtocol:Sending: CloseSecureChannelRequest(TypeId=FourByteNodeId(Identifier=452, NamespaceIndex=0, NodeIdType=<NodeIdType.FourByte: 1>), RequestHeader_=RequestHeader(AuthenticationToken=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Timestamp=datetime.datetime(2023, 2, 6, 13, 5, 17, 867210), RequestHandle=3, ReturnDiagnostics=0, AuditEntryId=None, TimeoutHint=1000, AdditionalHeader=ExtensionObject(TypeId=NodeId(Identifier=0, NamespaceIndex=0, NodeIdType=<NodeIdType.TwoByte: 0>), Body=None)))
INFO:asyncua.client.ua_client.UASocketProtocol:Request to close socket received
INFO:asyncua.client.ua_client.UASocketProtocol:Socket has closed connection

grafik

@oroulet
Copy link
Member

oroulet commented Feb 6, 2023

changes are fine for me

@oroulet
Copy link
Member

oroulet commented Feb 6, 2023

do you have a bug or you want to merge?

@AndreasHeine
Copy link
Member Author

let me figure out why OPC-F LDS rejects us!

@AndreasHeine
Copy link
Member Author

maybe found the issue:

Discovery Serversshall reject registrations if the serverUriprovided does not match the applicationUriin Server Certificateused to create the SecureChannel.

@AndreasHeine
Copy link
Member Author

@oroulet you can squash&merge ... its still not working with the OPC-F LDS but i am unable to figgure that out... its probably because of security settings... or mismatch of client or server configuration!
it always send a BadServiceUnsupported on RegisterServer-Request.

@oroulet oroulet merged commit 83d79f3 into FreeOpcUa:master Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants