Giter VIP home page Giter VIP logo

litenetlibtransport's People

Contributors

james-frowen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

litenetlibtransport's Issues

Errors on compiling scripts for Android build

Unity 2019.3.3
When compiling scripts for Android build, 3 errors occurred:

Assets\LiteNetLibTransport\LiteNetLibTransport.cs(242,30): error CS0508: 'LiteNetLibTransport.ClientSend(int, ArraySegment)': return type must be 'void' to match overridden member 'Transport.ClientSend(int, ArraySegment)'

Assets\LiteNetLibTransport\LiteNetLibTransport.cs(321,30): error CS0115: 'LiteNetLibTransport.ServerSend(List, int, ArraySegment)': no suitable method found to override

Assets\LiteNetLibTransport\LiteNetLibTransport.cs(11,18): error CS0534: 'LiteNetLibTransport' does not implement inherited abstract member 'Transport.ServerSend(int, int, ArraySegment)'

Steps:

  • import Noble Free Connect from AssetStore;
  • import Mirror from AssetStore;
  • import Mirror Noble Connect package from Noble folder;
  • import LiteNetLibTransport package from Releases (latest is v0.7.1 for now);
  • open Noble Connect / Mirror / Examples / NetworkManager / Example Mirror;
  • add LiteNetLibTransport to Example Noble Network Manager;
  • open Build Settings, switch to Android.

LiteNetLib does not respect Transport.enabled if the transport was disabled by another message within the same frame

Certain code in Mirror (specifically the scene load code) is dependent on pausing the transport on the client/server to ensure messages don't get sent out of order. As such, there are two checks within Telepathy.

            // note: we need to check enabled in case we set it to false
            // when LateUpdate already started.
            // (https://github.com/vis2k/Mirror/pull/379)
            if (!enabled)
                return;

            // process a maximum amount of client messages per tick
            for (int i = 0; i < clientMaxReceivesPerTick; ++i)
            {
                // stop when there is no more message
                if (!ProcessClientMessage())
                {
                    break;
                }

                // Some messages can disable transport
                // If this is disabled stop processing message in queue
                if (!enabled)
                {
                    break;
                }
            }

As it stands, this transport does not account for this. The current behavior will batch messages received while the transport is disabled, but it won't properly handle the frame boundaries (checkMessageQueues is set to true when the transport is disabled, so when the client/server exit their OnUpdate() poll, they'll end up checking the queue the same frame)

https://github.com/MirrorNetworking/LiteNetLibTransport/blob/master/source/LiteNetLibTransport.cs#L70

This will result in various errors when using additive scene loading, as there's race condition potential (the client can try and configure sceneobjects before the scene has fully loaded.)

There is a sample project attached to MirrorNetworking/Mirror#2033 that can be used to verify this behavior.

Support for IPv4-mapped IPv6 address

IPv4-mapped IPv6 addresses do not work properly with LiteNetLibTransport. An example of an address like this:
::ffff:192.168.1.6

Right now LiteNetLibTransport opens up two sockets, one for IPv4 and one for IPv6. An IPv4-mapped IPv6 address is treated as an IPv6 address, so it is routed to the IPv6 socket. Because an IPv4-mapped IPv6 address is fundamentally an IPv4 address, it requires an IPv4 socket. In C# this is handled through something called a dual-mode socket, which encapsulates both an IPv4 and IPv6 socket into one package. Non-dual mode IPv6 sockets (aka IPv6 only) sockets seem to be incapable of handling IPv4-mapped IPv6 addresses and will throw an exception if you try to send to an address like this. This makes perfect sense, since the program actually needs to use IPv4 under the hood.

If you try to use this type of address right now in LiteNetLib an exception is thrown:

[S]System.Net.Sockets.SocketException (0x80004005): The requested address is not valid in its context.

  at System.Net.Sockets.Socket.SendTo (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) [0x00082] in <d2957de1c3fd4781a43d89572183136c>:0 
  at LiteNetLib.NetSocket.SendTo (System.Byte[] data, System.Int32 offset, System.Int32 size, System.Net.IPEndPoint remoteEndPoint, System.Net.Sockets.SocketError& errorCode) [0x0003e] in D:\Caleb\holosproject\holos-desktop\Holos\Assets\LiteNetLibTransport\LiteNetLib\NetSocket.cs:427 
UnityEngine.Debug:Log(Object)
LiteNetLib.NetDebug:WriteLogic(NetLogLevel, String, Object[]) (at Assets/LiteNetLibTransport/LiteNetLib/NetDebug.cs:51)
LiteNetLib.NetDebug:WriteError(String, Object[]) (at Assets/LiteNetLibTransport/LiteNetLib/NetDebug.cs:89)
LiteNetLib.NetSocket:SendTo(Byte[], Int32, Int32, IPEndPoint, SocketError&) (at Assets/LiteNetLibTransport/LiteNetLib/NetSocket.cs:441)
LiteNetLib.NetManager:SendRaw(Byte[], Int32, Int32, IPEndPoint) (at Assets/LiteNetLibTransport/LiteNetLib/NetManager.cs:469)
LiteNetLib.NetManager:SendRaw(NetPacket, IPEndPoint) (at Assets/LiteNetLibTransport/LiteNetLib/NetManager.cs:448)
LiteNetLib.NetPeer:.ctor(NetManager, IPEndPoint, Int32, Byte, NetDataWriter) (at Assets/LiteNetLibTransport/LiteNetLib/NetPeer.cs:281)
LiteNetLib.NetManager:Connect(IPEndPoint, NetDataWriter) (at Assets/LiteNetLibTransport/LiteNetLib/NetManager.cs:1430)
LiteNetLib.NetManager:Connect(String, Int32, NetDataWriter) (at Assets/LiteNetLibTransport/LiteNetLib/NetManager.cs:1379)
LiteNetLib.NetManager:Connect(String, Int32, String) (at Assets/LiteNetLibTransport/LiteNetLib/NetManager.cs:1356)
LiteNetLibMirror.Client:Connect(String) (at Assets/LiteNetLibTransport/Client.cs:64)
Mirror.LiteNetLibTransport:ClientConnect(String) (at Assets/LiteNetLibTransport/LiteNetLibTransport.cs:177)
Mirror.NetworkClient:Connect(String) (at Assets/Mirror/Runtime/NetworkClient.cs:73)
Mirror.NetworkManager:StartClient() (at Assets/Mirror/Runtime/NetworkManager.cs:411)
TuringVR.Networking.HolosNetworkManager:NetworkDiscovery_OnDiscoveredServer(String, String) (at Assets/_Holos/Scripts/Networking/HolosNetworkManager.cs:186)
UnityEngine.Events.UnityEvent`2:Invoke(String, String)
TuringVR.Networking.LANNetworkDiscovery:OnReceivedBroadcast(String, String) (at Assets/_Holos/Scripts/Networking/LANNetworkDiscovery.cs:19)
UnityEngine.Networking.NetworkDiscovery:Update()

because the packet is being routed through the non-dual mode IPv6 socket. There are one of two possible fixes: use dual mode sockets, or handle IPv4-mapped IPv6 addresses as a special case and ensure they get routed through the IPv4 socket.

The fix for switching to dual mode is to change the IPv6Enabled to have value IPv6Mode.DualMode instead of IPv6Mode.SeparateSocket at https://github.com/MirrorNetworking/LiteNetLibTransport/blob/master/source/LiteNetLib/NetManager.cs#L294

Alternatively the IPv4-mapped IPv6 address can be parsed specially using https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.isipv4mappedtoipv6?view=netcore-3.1 and https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.maptoipv4?view=netcore-3.1

lose MaxConnectAttempts

old version have setting to configure MaxConnects

now, MaxConnectAttempts always will be 10

Support for Mirror 70?

I just started looking into porting all of my UNet stuff to Mirror and I need UDP support, so was looking into using the LiteNetLibTransport, however it does not compile with the current version of Mirror.

Are there plans to support this version? Is this repo still maintained?

NetworkConnection.ValidatePacketSize: cannot send packet larger than 508 bytes

508 bytes its fully unused lib...

as a see this, some problem in LiteNet Lib ? Las we use this, we have no that problem

  public override int GetMaxPacketSize(int channelId = Channels.DefaultReliable)
        {
            // LiteNetLib NetPeer construct calls SetMTU(0), which sets it to
            // NetConstants.PossibleMtu[0] which is 576-68.
            // (bigger values will cause TooBigPacketException even on loopback)
            //
            // see also: https://github.com/RevenantX/LiteNetLib/issues/388
            return NetConstants.PossibleMtu[0];
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.