Connection with WEB API deployied in IIS

96 Views Asked by At

I am working on .NET web api to create a kind of tunneling for Classic OPC DA server. To connect to the OPC server I am using the TitaniunAS.OPC library. The Web API works find when running from Visual Studio (as usual). My problem start when I try to deploy this Web app in a IIS server. The problem I am having is, as far as I believe, related to user configuration.

To connect to the OPC server I need that the client runs with a specific user (let's call it opc_user). If I deploy the Web API in the IIS with standard settings (using ApplicationPollIndetity in the Identity parameter of Applicaiton Poll of this web api) I receive a error from the request saying that the connection to the OPC server was refused. The error make it clear that the request was sent to the Web API function and it failed in stablishing the connection to the OPC server. The OPC server/client communicaiton is based on DCOM.

Error connecting to host <hostname> because 
System.Runtime.InteropServices.ExternalException (0x80070005): CoCreateInstanceEx: Access is denied.
at TitaniumAS.Opc.Client.Interop.System.Com.CreateInstance(Guid clsid, String host, NetworkCredential credential)
at TitaniumAS.Opc.Client.Interop.System.Com.CreateInstanceWithBlanket(Guid clsid, String host, NetworkCredential credential, ComProxyBlanket comProxyBlanket)
at TitaniumAS.Opc.Client.Common.OpcServerEnumeratorAuto.CLSIDFromProgId(String progId, String host)
at TitaniumAS.Opc.Client.Da.OpcDaServer.<>c__DisplayClass19_0.<Connect>b__0(String host, String progId)
at TitaniumAS.Opc.Client.Common.UrlParser.Parse[T](Uri opcServerUrl, Func`3 withProgId, Func`3 withCLSID)
at TitaniumAS.Opc.Client.Da.OpcDaServer.Connect()\r\n   at RestOPC.Controllers.ValuesController.Read(OPCrequestRead data) 
in C:\\...\\ValuesController.cs:line 54

So, knowing this, I tried to set the Indentity of the Application poll to this opc_user which is able to connect to the OPC server. Doing that now I start getting a error saying that the request to the web api was refused.

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

I believe that the solution is in making this opc_user being able to call the web api. I just didn't figure out how to do that in IIS or Windows Server configuration.

Any Idea?

0

There are 0 best solutions below