GlaireDaggers / Netcode.IO.NET

A pure managed C# implementation of the Netcode.IO spec
MIT License
255 stars 47 forks source link

Connect token expired (Linux) #9

Closed Danila24ru closed 7 years ago

Danila24ru commented 7 years ago

time

So, I getting error on Linux server when connecting from windows client. What's wrong?

C#factory.GenerateConnectToken(ipEndPoint,30, 10, 1, localClientID, new byte[256]) I see

        /// <summary>
        /// Gets the Unix timestamp of the DateTime object
        /// </summary>
        public static ulong ToUnixTimestamp(this DateTime time)
        {
            return (ulong)Math.Truncate(time.GetTotalSeconds());
        }

But where I should use it?

Danila24ru commented 7 years ago

UPD: I converted timestamp in this debug to time, there difference in 1 hour, it's uses different time?

GlaireDaggers commented 7 years ago

GenerateConnectToken automatically converts the machine's local time to a Unix timestamp - which it does by using DateTime.Now, converting that to a Universal time via ToUniversalTime, and then subtracting a new DateTime( 1970, 1, 1 ) and getting the total seconds. I'd say try logging the results of DateTime.Now.ToUniversalTime, both on your Windows machine and on your Linux machine, and comparing the two. Also check the system clocks and make sure they're correct.

Danila24ru commented 7 years ago

Okay, it's works, I just made asp.net server with token generator on linux.