# I cannot connect to ignition server from C/C++ codes

**URL:** <https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912>\
**Category:** General Discussion\
**Created:** [May 6, 2025, 12:36pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912 "2025-05-06T12:36:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 12:36pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/1 "2025-05-06T12:36:45Z")

</div>

I tried to connect to my local OPC UA server with Anonymous and No security, but failed with the following code (0x80ad0000). See the below code:

```python
UA_StatusCode status = UA_STATUSCODE_GOOD;
std::unique_ptr<UA_Client, decltype(&UA_Client_delete)> client(UA_Client_new(), UA_Client_delete);
UA_ClientConfig* cfg = UA_Client_getConfig(client.get());
status = UA_ClientConfig_setDefault(cfg);
//status == UA_STATUSCODE_GOOD;

// Endpoint URL of the Ignition OPC UA server
const char* endpointUrl = "opc.tcp://localhost:62541";
//const char* endpointUrl = "opc.tcp://localhost:62541/discovery";

status = UA_Client_connect(client.get(), endpointUrl);
//status == UA_STATUSCODE_BADDISCONNECT (0x80ad0000)

```

However, I can use Prosys OPC UA Monitor to connect to my local ignition OPC UA Server. Please help me show me my code problem.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1a4fcfb3188e4e23116aecdeddc08f8a5f0ffb48.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 12:40pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/2 "2025-05-06T12:40:33Z")

</div>

You'll need to provide more information... how about logs from your Client program and from Ignition? Wireshark captures?

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 12:50pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/3 "2025-05-06T12:50:41Z")

</div>

Thanks a lot for your fast response. Here is my console output:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e60763f3f2409df9dbfdd5575148c1f655f4661.png)

I don't know how I can get a log file. Remember I am writing C/C++ codes. The same code works for Prosys OPC UA Simulation Server nicely.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 12:56pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/4 "2025-05-06T12:56:22Z")

</div>

I'm not familiar with the library you're using, but it looks like you're not even getting as far as being able to open a TCP connection to the Ignition server.

I don't know why that would be the case when Prosys client is able to connect without issue. This indicates it's probably not an issue with the Ignition configuration. I assume all of this software (Ignition, prosys, your C++ app) is running locally. Maybe some permissions on your C++ executable or firewall permissions?

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 1:08pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/5 "2025-05-06T13:08:48Z")

</div>

I don't think there are permission issues at all because all servers and clients are running locally. I can use the same above code snippet to connect with Prosys OPC UA Simulation Server without any issue at all. I am a very beginner to OPC UA.  
Does your company have C/C++ developer to test my code snippet for me?

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 1:12pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/6 "2025-05-06T13:12:34Z")

</div>

Here are OPC UA settings:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd3b471a453955a9da363dc86a2b49d3e041628a.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd9d8a789996f2af85e9363c06c0996f6832a22d.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 1:13pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/7 "2025-05-06T13:13:36Z")

</div>

> [@charlie.ye](#):
>
> Does your company have C/C++ developer to test my code snippet for me?

No. This is your problem to deal with. I can offer assistance with the Ignition and OPC UA aspect.

Those settings look okay. You do need to restart the Gateway for any changes to take effect.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 1:23pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/8 "2025-05-06T13:23:45Z")

</div>

Try "127.0.0.1" instead of "localhost" in the endpoint URL you use in your client?

Maybe something funny going on there.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 6, 2025, 2:18pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/9 "2025-05-06T14:18:47Z")

</div>

Your banner on your gateway shows trial expired. Don't forget to reset the trial time while testing.

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 2:45pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/10 "2025-05-06T14:45:32Z")

</div>

I have just reset it. I still get the same errors (UA\_STATUSCODE\_BADDISCONNECT (0x80ad0000)) with end point url (opc.tcp://localhost:62541):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/c/cc24cb761d583dda114b0f1a0029d56ec1c67415.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1ae4afcf26246403c3be74877934900d41345e15.png)

If I use the end point url (opc.tcp://127.0.0.1:62541), I get the errors (UA\_STATUSCODE\_BADSERVICEUNSUPPORTED (0x800b0000)).

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d8d9d10abdb5c76cdba31ae224314a5a49f0c9f9.png)

However, if I use Prosys OPC UA simulation server with the end point url: opc.tcp://ATL-DEV-CY-04.DataManag.local:53530/OPCUA/SimulationServer, I get everything works perfectly.

I am sure your company OPC UA server has a connection flaw because the same code snippet does work with other OPC UA server.

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 2:46pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/11 "2025-05-06T14:46:26Z")

</div>

Here is the output for Prosys OPC UA simulation server:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd362a00972f20d5c3e16aa9520ef97c83ae58e8.png)

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 2:47pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/12 "2025-05-06T14:47:46Z")

</div>

I have already restarted my machine after installing ignition OPC UA server.

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 2:49pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/13 "2025-05-06T14:49:36Z")

</div>

Do you have some C/C++ code snippet for me to test it against your Ingnition OPC UA server?

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 2:59pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/14 "2025-05-06T14:59:18Z")

</div>

Your ignition OPC UA server refuses (opc.tcp://localhost:62541/discovery or opc.tcp://localhost:62541) directly. However, Prosys OPC UA server is able to select a correct end point url when a client is configured with 'UserTokenType Anonymous and SecurityPolicy [Profile Reporting Links](http://opcfoundation.org/UA/SecurityPolicy#None)'.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 3:05pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/15 "2025-05-06T15:05:50Z")

</div>

It looks like using 127.0.0.1 solved the connection issue and you have a different problem after that.

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 3:14pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/16 "2025-05-06T15:14:50Z")

</div>

Wrong! your ignition OPC UA server still has an issue with 127.0.0.1 with error code UA\_STATUSCODE\_BADSERVICEUNSUPPORTED.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 3:21pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/17 "2025-05-06T15:21:17Z")

</div>

Wrong!

your client has an issue.

It's probably trying to call the CreateSession service against the discovery endpoint at `opc.tcp://localhost:62541/discovery` instead of the session endpoint at `opc.tcp://localhost:62541`.

Share a Wireshark capture and we'll see.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/18 "2025-05-06T15:36:23Z")

</div>

I just compiled and ran [this open62541 example](https://github.com/open62541/open62541/blob/7e8ec6206a89b93f9566ea47856120387809cae2/examples/tutorial_client_firststeps.c), changing only the endpoint URL, and it connected to the Ignition OPC UA server without issue.

```python
kevin@DV-kevin ~/D/open62541> gcc -std=c99 tutorial_client_firststeps.c -lopen62541 -o client
kevin@DV-kevin ~/D/open62541> ./client
[2025-05-06 08:36:02.159 (UTC-0700)] warn/client Skip verifying ApplicationURI for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None
[2025-05-06 08:36:02.160 (UTC-0700)] info/network TCP 3 | Opening a connection to "127.0.0.1" on port 62541
[2025-05-06 08:36:02.168 (UTC-0700)] info/channel TCP 3 | SC 2 | SecureChannel opened with SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None and a revised lifetime of 600.0s
[2025-05-06 08:36:02.168 (UTC-0700)] info/client Client Status: ChannelState: Open, SessionState: Closed, ConnectStatus: Good
[2025-05-06 08:36:02.171 (UTC-0700)] info/client Use the EndpointURL opc.tcp://127.0.0.1:62541/discovery returned from FindServers and reconnect
[2025-05-06 08:36:02.172 (UTC-0700)] info/channel TCP 3 | SC 2 | SecureChannel closed
[2025-05-06 08:36:02.172 (UTC-0700)] warn/client Skip verifying ApplicationURI for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None
[2025-05-06 08:36:02.172 (UTC-0700)] info/network TCP 6 | Opening a connection to "127.0.0.1" on port 62541
[2025-05-06 08:36:02.172 (UTC-0700)] info/network TCP 3 | Socket closed
[2025-05-06 08:36:02.179 (UTC-0700)] info/channel TCP 6 | SC 3 | SecureChannel opened with SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None and a revised lifetime of 600.0s
[2025-05-06 08:36:02.179 (UTC-0700)] info/client Client Status: ChannelState: Open, SessionState: Closed, ConnectStatus: Good
[2025-05-06 08:36:02.181 (UTC-0700)] warn/client The server returned Endpoints with a different EndpointUrl opc.tcp://127.0.0.1:62541/discovery than was used to initialize the connection: opc.tcp://127.0.0.1:62541/discovery. Some servers require a complete match of the EndpointUrl/DiscoveryUrl (including the path) to return all endpoints.
[2025-05-06 08:36:02.181 (UTC-0700)] info/client Selected endpoint with EndpointUrl opc.tcp://127.0.0.1:62541, SecurityMode None and SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None
[2025-05-06 08:36:02.181 (UTC-0700)] info/channel TCP 6 | SC 3 | SecureChannel closed
[2025-05-06 08:36:02.181 (UTC-0700)] warn/client Skip verifying ApplicationURI for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None
[2025-05-06 08:36:02.181 (UTC-0700)] info/network TCP 3 | Opening a connection to "127.0.0.1" on port 62541
[2025-05-06 08:36:02.181 (UTC-0700)] info/network TCP 6 | Socket closed
[2025-05-06 08:36:02.185 (UTC-0700)] info/channel TCP 3 | SC 4 | SecureChannel opened with SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None and a revised lifetime of 600.0s
[2025-05-06 08:36:02.185 (UTC-0700)] info/client Client Status: ChannelState: Open, SessionState: Closed, ConnectStatus: Good
[2025-05-06 08:36:02.246 (UTC-0700)] info/client Client Status: ChannelState: Open, SessionState: Created, ConnectStatus: Good
[2025-05-06 08:36:02.247 (UTC-0700)] info/client Client Status: ChannelState: Open, SessionState: Activated, ConnectStatus: Good
[2025-05-06 08:36:02.254 (UTC-0700)] info/userland date is: 6-5-2025 15:36:2.253
[2025-05-06 08:36:02.258 (UTC-0700)] info/channel TCP 3 | SC 4 | SecureChannel closed
[2025-05-06 08:36:02.258 (UTC-0700)] info/client Client Status: ChannelState: Fresh, SessionState: Closed, ConnectStatus: BadConnectionClosed
[2025-05-06 08:36:02.258 (UTC-0700)] info/network TCP 3 | Socket closed
kevin@DV-kevin ~/D/open62541> 

```

---

<div class="post-metadata">

**Author:** ![charlie.ye](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charlie.ye](https://forum.inductiveautomation.com/u/charlie.ye)\
**Post date:** [May 6, 2025, 3:55pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/19 "2025-05-06T15:55:49Z")

</div>

How about windows platform? I am working with Visual C++ 2022 on windows 11 platform. Thanks a lot for your help. Does your company have someone who has some experience with Visual C++ 2022 on window platforms? I have reached the max posts here and I need to wait another 20 hours before posting a new topic.

I still have the max post issue.

Thanks a lot for your help. I moved into a new window machine.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/1/912b5a3095c46b199f700687766cf871c8f127fe.jpeg)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/27bb155d50ae64f1c20b9dcfa8c882218a9a92fc.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28c952603c958772b7dc5913ed7b0f60b2dcd8ab.png)

I still have the connection problem. Let me check Ignition Server settings.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2025, 3:59pm UTC](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912/20 "2025-05-06T15:59:01Z")

</div>

I don't have a Windows laptop or even any experience using Visual C++.

[Next page](https://forum.inductiveautomation.com/t/i-cannot-connect-to-ignition-server-from-c-c-codes/105912.md?page=2)
