04/11/2017
Hi,
I’m trying to use Unity3D (an interaction engine) as a Client to connect to an OPC Server.
I’m able to connect to the Server when executing my script in a Console application. However, if I adapt the script to Unity and run it from there, I get the following error message:
ServiceResultException: Error establishing a connection.
Opc.Ua.Bindings.TcpAsyncOperation`1[System.Int32].End (Int32 timeout)
Opc.Ua.Bindings.TcpClientChannel.EndSendRequest (IAsyncResult result)
Opc.Ua.Bindings.TcpTransportChannel.EndSendRequest (IAsyncResult result)
Opc.Ua.Bindings.TcpTransportChannel.SendRequest (IServiceRequest request)
Opc.Ua.DiscoveryClient.GetEndpoints (Opc.Ua.RequestHeader requestHeader, System.String endpointUrl, Opc.Ua.StringCollection localeIds, Opc.Ua.StringCollection profileUris, Opc.Ua.EndpointDescriptionCollection& endpoints)
Opc.Ua.DiscoveryClient.GetEndpoints (Opc.Ua.StringCollection profileUris)
Opc.Ua.ConfiguredEndpoint.UpdateFromServer (Opc.Ua.BindingFactory bindingFactory, System.Uri endpointUrl, MessageSecurityMode securityMode, System.String securityPolicyUri)
Opc.Ua.ConfiguredEndpoint.UpdateFromServer (Opc.Ua.BindingFactory bindingFactory)
Opc.Ua.Client.Session.Create (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.ConfiguredEndpoint endpoint, Boolean updateBeforeConnect, Boolean checkDomain, System.String sessionName, UInt32 sessionTimeout, IUserIdentity identity, IList`1 preferredLocales)
Opc.Ua.Client.Session.Create (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.ConfiguredEndpoint endpoint, Boolean updateBeforeConnect, System.String sessionName, UInt32 sessionTimeout, IUserIdentity identity, IList`1 preferredLocales)
script_connectOPC.Start () (at Assets/Resources/script_connectOPC.cs:47)
Has anyone on here any tips on how to connect to an OPC Server from Unity3D?
07/08/2015
ragnar.thomsen@ipk.fraunhofer.de said
Hi,I’m trying to use Unity3D (an interaction engine) as a Client to connect to an OPC Server.
I’m able to connect to the Server when executing my script in a Console application. However, if I adapt the script to Unity and run it from there, I get the following error message:
ServiceResultException: Error establishing a connection.
Opc.Ua.Bindings.TcpAsyncOperation`1[System.Int32].End (Int32 timeout)
Opc.Ua.Bindings.TcpClientChannel.EndSendRequest (IAsyncResult result)
Opc.Ua.Bindings.TcpTransportChannel.EndSendRequest (IAsyncResult result)
Opc.Ua.Bindings.TcpTransportChannel.SendRequest (IServiceRequest request)
Opc.Ua.DiscoveryClient.GetEndpoints (Opc.Ua.RequestHeader requestHeader, System.String endpointUrl, Opc.Ua.StringCollection localeIds, Opc.Ua.StringCollection profileUris, Opc.Ua.EndpointDescriptionCollection& endpoints)
Opc.Ua.DiscoveryClient.GetEndpoints (Opc.Ua.StringCollection profileUris)
Opc.Ua.ConfiguredEndpoint.UpdateFromServer (Opc.Ua.BindingFactory bindingFactory, System.Uri endpointUrl, MessageSecurityMode securityMode, System.String securityPolicyUri)
Opc.Ua.ConfiguredEndpoint.UpdateFromServer (Opc.Ua.BindingFactory bindingFactory)
Opc.Ua.Client.Session.Create (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.ConfiguredEndpoint endpoint, Boolean updateBeforeConnect, Boolean checkDomain, System.String sessionName, UInt32 sessionTimeout, IUserIdentity identity, IList`1 preferredLocales)
Opc.Ua.Client.Session.Create (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.ConfiguredEndpoint endpoint, Boolean updateBeforeConnect, System.String sessionName, UInt32 sessionTimeout, IUserIdentity identity, IList`1 preferredLocales)
script_connectOPC.Start () (at Assets/Resources/script_connectOPC.cs:47)Has anyone on here any tips on how to connect to an OPC Server from Unity3D?
I was getting the same error, I added this after config.Validate(ApplicationType.Client);
ITransportChannel channel = WcfChannelBase.CreateUaBinaryChannel(config, new EndpointDescription(“opc.tcp://localhost:62657”), endpointConfiguration, clientCertificate, config.CreateMessageContext());
and now I’m getting the next error:
NullReferenceException: Object reference not set to an instance of an object
Opc.Ua.Bindings.TcpTransportChannel.SaveSettings (System.Uri url, Opc.Ua.TransportChannelSettings settings) (at <881109fbf76148f0841e7c4912cf3ab4>:0)
Opc.Ua.Bindings.TcpTransportChannel.Initialize (System.Uri url, Opc.Ua.TransportChannelSettings settings) (at <881109fbf76148f0841e7c4912cf3ab4>:0)
Opc.Ua.WcfChannelBase.CreateUaBinaryChannel (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.EndpointDescription description, Opc.Ua.EndpointConfiguration endpointConfiguration, System.Security.Cryptography.X509Certificates.X509Certificate2 clientCertificate, Opc.Ua.ServiceMessageContext messageContext) (at <881109fbf76148f0841e7c4912cf3ab4>:0)
1 Guest(s)