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

Socket error on Azure app service #14

Open
theguy69 opened this issue Sep 16, 2023 · 6 comments
Open

Socket error on Azure app service #14

theguy69 opened this issue Sep 16, 2023 · 6 comments

Comments

@theguy69
Copy link

I'm getting this error:

Error: System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call. [::ffff:194.117.47.42]:123
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at GuerrillaNtp.NtpClient.Connect()
at GuerrillaNtp.NtpClient.Query()

When using in a Azure App, running local don't throw error.

Code used

//NtpClient client = new NtpClient("ntp02.oal.ul.pt");
NtpClient client = new NtpClient(IPAddress.Parse("194.117.47.42"));
NtpClock clock = client.Query();

Any idea how to solve this?

Cheers

Jorge

@robertvazan
Copy link
Owner

The "invalid pointer address" looks like an internal NET problem. I don't use Azure. Could you try writing a small program that just calls Connect() on a UDP socket? If it fails, we know it's not GuerrillaNTP-related.

@theguy69
Copy link
Author

theguy69 commented Sep 16, 2023

Hi Robert,

The error has been identified and can be resolved with a few small changes to your code. For some strange reason, Azure always tries to connect via IPV6, I think if you create an overload of the NtpClient method to include the possibility of choosing the range of addresses the problem will be solved, the following code does not generate an error in Azure:

var teste = new DnsEndPoint("ntp02.oal.ul.pt", 123);
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Connect(teste);
socket.Close();

If i Remove the AddressFamily Azure throws one exception error.

Just add the parameter to NtpClient and change all socket connections to include the parameter if defined *if not defined use the default value AddressFamily.Unspecified
Ex:

NtpClient client = new NtpClient("ntp02.oal.ul.pt", 123, AddressFamily.InterNetwork);
or
NtpClient client = new NtpClient("ntp02.oal.ul.pt", AddressFamily.InterNetwork);

Hope this helps you to solve the issue

Cheers
Jorge

@robertvazan
Copy link
Owner

Good analysis. Would you be able to make a pull request with the API changes you are proposing?

@theguy69
Copy link
Author

Hi Robert

Created the pull request, if you use it and after you update the Nudget Package I'll try it on production server.

Cheers

Jorge

@theguy69
Copy link
Author

theguy69 commented Oct 6, 2023

Hi Robert

Did you have the opportunity to check the pull request I made regarding this error?

Still saying that needs to be approved by a maintainer

Cheers

Jorge

@robertvazan
Copy link
Owner

I am a bit busy, but it's on my priority TODO list. I will get to it as soon as possible.

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

2 participants