So, I do not have IPv6 on my target machine but still the server tries to create an IPv6 server, which of course fails.
My hack to work around this, as described above, does not feel right. I do not want to an intrusive hack requiring me to modify UA sources.
Instead, I created a non-intrusive work-around, which is a better solution that I share for others having the same problem.
Internally, there is a variable default initialized to prefer IPv6. Fortunately there is a macro definition OPCUA_P_SERVER_PREFER_INET6 (that is default set to !0) that one can change to 0, which causes the internal variable to not prefer IPv6. This will select IPv4 over IPv6 and that allows the server socket to be created as an IPv4 socket using our hostname as endpointUrl.
In our CMake-file I simply added (after the add_library(uastack) has been created of course):
Code: Select all
target_compile_definitions(uastack PRIVATE OPCUA_P_SERVER_PREFER_INET6=0)
Actually, I created a CMake option that checks whether IPv6 is to be disabled or not and then, in an if-statement, I set the uastack target's compile definition to OPCUA_P_SERVER_PREFER_INET6=0.
I think the current UA implementation, which tries to create an IPv6 server despite IPv6 is not available, is a bug.
Also I think it would be nice to have a well-documented way to enable or disable IPv6 (and IPv4).
Regards,
/Tommy