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

System.Net.EndPoint.Serialize throws System.NotImplementedException on Mono Linux #16

Open
schtibb opened this issue Nov 12, 2018 · 2 comments

Comments

@schtibb
Copy link

schtibb commented Nov 12, 2018

Yort uses EndPoint as a parameter to Socket.Connect, the Serialize method is not implemented in Mono Linux which results in the exception below. In order to be compatible with Mono Linux/Android etc IPEndPoint could be used instead.

try {
 var client = new NtpClient(_ntpServer);
 Task < RequestTimeResult > task = client.RequestTimeAsync();
 task.Wait();
 var currentTime = task.Result;
 return currentTime.NtpTime.CreateUnixTimeStamp();
} catch (Exception exception) {
 _loggingService.Error($ "Error while syncing time with NTP: {exception}");
 throw;
}

Yort.Ntp.NtpNetworkException: This method is not implemented by this class. ---> System.NotImplementedException: This method is not implemented by this class.
at System.Net.EndPoint.Serialize () [0x00005] in <41574d2cca96494f8f406b75a489d430>:0
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00070] in <41574d2cca96494f8f406b75a489d430>:0
at Yort.Ntp.NtpClient.SendTimeRequest () [0x00092] in :0
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in :0
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in :0
at System.Threading.Tasks.Task.Wait () [0x00000] in :0
at Services.NtpSyncService.GetTime () [0x000aa] in <461fb7cf28f04e90bf48c2b50181c3b6>:0
---> (Inner Exception #0) Yort.Ntp.NtpNetworkException: This method is not implemented by this class. ---> System.NotImplementedException: This method is not implemented by this class.
at System.Net.EndPoint.Serialize () [0x00005] in <41574d2cca96494f8f406b75a489d430>:0
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00070] in <41574d2cca96494f8f406b75a489d430>:0
at Yort.Ntp.NtpClient.SendTimeRequest () [0x00092] in :0
--- End of inner exception stack trace ---<---

@schtibb
Copy link
Author

schtibb commented Nov 12, 2018

I looked at the code and this seems to be handled for Android. However it won't work on Mono Linux. In order for it to work for Mono Linux, IPEndpoint needs to be always used.

@Yortw
Copy link
Owner

Yortw commented Oct 6, 2024

You're correct this was handled for Android, I didn't realise it didn't work on Linux as well.

There is a new beta package at https://www.nuget.org/packages/Yort.Ntp/3.0.1-beta (note the new package id) which you could try. This supports net8.0-android and ios targets, so in theory should work with Maui. My access to platforms for testing is somewhat limited right now, so if you do try it I'd appreciate any feedback you have on success of failure of the new package.
I have tried it in a .net 8.0 console app on WSL 2 in the Ubuntu distro, and it seems to work there now.

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