OPC UA and Unity3D|Product and Service Requests|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
OPC UA and Unity3D
Avatar
Ragnar Thomsen
New Member
Members
Forum Posts: 1
Member Since:
04/11/2017
sp_UserOfflineSmall Offline
1
04/18/2017 - 07:39
sp_Permalink sp_Print

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?

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
10/03/2017 - 09:46
sp_Permalink sp_Print

Given the error the TCP stack cannot resolved the domain or port passed in the URL.

This can because of a bad URL, problem with DNS, a problem with the networking layer, a firewall or network routing issue.

Avatar
Sean MacDonald
New Member
Members
Forum Posts: 2
Member Since:
01/25/2018
sp_UserOfflineSmall Offline
3
02/09/2018 - 13:03
sp_Permalink sp_Print

Any luck with this?  I have been trying to do the same thing....

Sean MacDonald

Avatar
OSCAR RUDAS
New Member
Members
Forum Posts: 1
Member Since:
07/08/2015
sp_UserOfflineSmall Offline
4
11/15/2018 - 19:35
sp_Permalink sp_Print

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)

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855