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

UA_Client_connect() is blocking #6460

Open
2 tasks
spole340 opened this issue May 7, 2024 · 2 comments
Open
2 tasks

UA_Client_connect() is blocking #6460

spole340 opened this issue May 7, 2024 · 2 comments

Comments

@spole340
Copy link

spole340 commented May 7, 2024

Description

I tried to run example client_connect_loop.c, but the function UA_Client_connect() is blocking when OPC server is unreachable.
The program stuck here and if server is reachable it is not reconnected. I want to use UA_Client_connectUsername() insteat of UA_Client_connect(), but behavior is same (blocking). I need non blocking function that returns me something if something wrong. Can someone help me, please?

Background Information / Reproduction Steps

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag):
  • Operating system: Ubuntu 22.04
@jpfr
Copy link
Member

jpfr commented May 19, 2024

Are you using the 1.4 version?

we have dedicated _async versions for the connect methods. Use those.

It can take some time for the connection to fail. That depends on the DNS timeout configured in your operating system.

@Schokoladenblau
Copy link

Schokoladenblau commented Jun 20, 2024

I got the same error. The log shows the folling:
[2024-06-20 12:48:11.789 (UTC+0000)] info/eventloop Starting the EventLoop
[2024-06-20 12:48:11.789 (UTC+0000)] warn/client skip verifying ApplicationURI for the SecurityPolicy http:https://opcfoundation.org/UA/SecurityPolicy#None
[2024-06-20 12:48:11.789 (UTC+0000)] info/network TCP 8 | Opening a connection to "192.168.0.1" on port 4840
[2024-06-20 12:48:13.848 (UTC+0000)] info/network TCP 8 | The connection closes with error 111
[2024-06-20 12:48:13.848 (UTC+0000)] info/channel TCP 8 | SC 0 | SecureChannel closed
[2024-06-20 12:48:13.848 (UTC+0000)] error/client Could not open a TCP connection to the Endpoint at opc.tcp:https://192.168.0.1:4840
[2024-06-20 12:48:13.848 (UTC+0000)] info/client Client Status: ChannelState: Fresh, SessionState: Closed, ConnectStatus: BadConnectionRejected
[2024-06-20 12:48:13.848 (UTC+0000)] info/network TCP 8 | Socket closed

But after that the function doas not return, it gets stuck.
Git commit hash is 3d0da9a
I am using it inside Docker with the base image mcr.microsoft.com/devcontainers/cpp:1-debian-11

Note: If the Server is reachable everything works fine.

I now switched to the async way but got surprised, that the async function leads to periodic retrys to connect without me specifing to do so. This also didn't stop after quitting the while loop or callin Client_disconnect. The only way I found to stop that was by calling Client_delete which feels wrong to me... But this might be a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants