Code Monkey home page Code Monkey logo

lidgren-network-gen3's People

Contributors

agentfire avatar aienabled avatar badartefact avatar boonkerz avatar callumdev avatar chrisnobrega avatar danielcrenna avatar forestrf avatar hide1202 avatar italytoast avatar j-mie avatar jiiimmyyn avatar joshjje avatar laurentg-nvizzio avatar lidgren avatar michaeldepiazzi avatar mudcrab2142 avatar pjb3005 avatar revenantx avatar revolupowered avatar therzok avatar zsebastian avatar

Stargazers

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

Watchers

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

lidgren-network-gen3's Issues

Windows in airplane mode gives an error.

Putting windows 10 in airplane mode (or having wifi disabled) generates a null reference exception. Lidgren tries to aquire an ip address but in airplane mode there is no ip address available.

I came by this when using Lidgren in Unity3D.

(partial) stack trace below.

NullReferenceException: Object reference not set to an instance of an object
Lidgren.Network.NetUtility.GetBroadcastAddress () (at Assets/Scripts/External/Lindgren/Platform/PlatformWin32.cs:86)
Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) (at Assets/Scripts/External/Lindgren/NetPeerConfiguration.cs:98)

Using statistics

Hi,

I'm trying to use the Statistics class.
I don't know why, It ain't working for me.

Can you upload an example for using this class?
I cant find any info about it.

Thanks.

Linux support removed/broken in latest commit? (FIXED in Commit: 59995cc)

Hi Lidgren,

Thanks for a great open source library!

In your latest commit, it seems as though Linux support has been removed - we are getting an exception in the NetPeerConfiguration constructor on our Linux server.

The exception is as follows:

NotImplementedException: The requested feature is not implemented.
  at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask() [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetUtility.GetBroadcastAddress () [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) [0x00000] in <filename unknown>:0
  at Game.Server.GameServer.Awake () [0x00000] in <filename unknown>:0

This exception appears on our rented Linux server running 64 bit Ubuntu. We're using Unity 5.
Locally there are no issues on Windows 8.1

I hope you can fix this issue quickly, as we are really enjoying using your library - but Linux support is a must for us.

Thanks in advance!

License and Nuget package

Hi there,

since I'm unable to find a license file, am I correct to assume that it is still being published under the MIT license like the google code repo? If so, could you add this to your repo to clear further confusion (or point me right to it because I was blind), please?

Another quick question: Would you mind to create a nuget package for this repository as well? I plan on using your library and it would make my job easier ;)

Thanks
Kittyfisto

System.Net.Sockets.SocketException

I get a

System.Net.Sockets.SocketException
The descriptor is not a socket

when I Start(); on a NetPeer object.
this only happens while running debug, and if I continue it continues to run fine.
however it's a pain when I'm attempting to debug something and having to continue the process whenever I start a server or client.

I'm not sure why the exception is getting hit.

debugging with monodevelop 7.1 on linux mint.

Disconnect don't get recognized by lidgren

EDIT: I'm very very sorry for the inconvenience. It was my fault, I messed up some task continuations which resulted in never calling shutdown. I should have known better. You might delete this issue. Sorry.

Hello,

I'm using lidgren for some sort of remote controlling (not visually, just values). So far it's implemented like I used to implement it in all projects. It works perfectly fine so far, connecting does work properly.

The thing is: When I call NetPeer.Shutdown() or NetClient.Disconnect() on either the server or client, nothing happens. The opposite won't get informed about any status changes.

Could it be that the application gets terminated before the NetPeer internally is able to send the last messages? How could I possibly wait for them to finish? The shutdown gets called on application exit (WinForm or WPF). I can't haphazardly wait a second or so. This would slow down application exits which is a total no-go.

I am using the newest version (pulled on 12.09.2015). Here's my client / server configuration:
Server

            _config = new NetPeerConfiguration(SetupConsts.NET_APP_ID)
            {
                Port = SetupConsts.NET_DEFAULT_PORT
            };
            _config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            _config.EnableMessageType(NetIncomingMessageType.StatusChanged);
            _server = new NetServer(_config);

Client

            _config = new NetPeerConfiguration(SetupConsts.NET_APP_ID);
            _config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            _client = new NetClient(_config);

I'm willing to give more source code if required (via E-Mail).

And as little offtopic question: I tried it in local network from Laptop to my dev PC. Hosting the server on the laptop works, my application connects from the dev PC to it. But it doesn't find the server if I do it vice-versa. How comes?

Thread safety issue

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
at Lidgren.Network.NetPeer.Heartbeat() in Lidgren.Network\NetPeer.Internal.cs:line 342
at Lidgren.Network.NetPeer.NetworkLoop() in Lidgren.Network\NetPeer.Internal.cs:line 227

NetPeer.m_handshakes appear to not work correctly when NetIncomingMessageType.ConnectionApproval is enabled.

I'll continue to try to find the problem.

Does not run on Unity/Android

I compiled my working (Unity Windows) to Android and I receive this error:

I cannot add the define ANDROID as I need a replacement for this line of code:

Android.Net.Wifi.WifiManager wifi = (Android.Net.Wifi.WifiManager)Android.App.Application.Context.GetSystemService(Android.App.Activity.WifiService);

04-28 02:34:30.886: D/Unity(1350): Unable to lookup library path for 'libc', native render plugin support disabled.
04-28 02:34:30.886: E/Unity(1350): Unable to find libc
04-28 02:34:30.890: D/Unity(1350): Unable to lookup library path for 'libc', native render plugin support disabled.
04-28 02:34:30.890: E/Unity(1350): Unable to find libc
04-28 02:34:30.894: D/Unity(1350): Unable to lookup library path for 'libc', native render plugin support disabled.
04-28 02:34:30.894: E/Unity(1350): Unable to find libc
04-28 02:34:30.898: D/Unity(1350): Unable to lookup library path for 'libc', native render plugin support disabled.
04-28 02:34:30.898: E/Unity(1350): Unable to find libc
04-28 02:34:30.998: I/Unity(1350): NullReferenceException: Object reference not set to an instance of an object
04-28 02:34:30.998: I/Unity(1350): at Lidgren.Network.NetPeer.InitializeNetwork () [0x000df] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\Lidgren.Network\NetPeer.Internal.cs:188
04-28 02:34:30.998: I/Unity(1350): at Lidgren.Network.NetPeer.Start () [0x0005f] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\Lidgren.Network\NetPeer.cs:151
04-28 02:34:30.998: I/Unity(1350): at Lidgren.MatchMaking.Client..ctor (System.String name, System.String masterServerKey, System.String masterServerIP, Int32 masterServerPort) [0x001df] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.MM\MatchMaking.cs:83
04-28 02:34:30.998: I/Unity(1350): at MultiplayerTest+c__Iterator1.MoveNext () [0x00031] in C:\Users\David\Documents\LidgrenTest\Assets\MultiplayerTest.cs:17

Assemblies should have valid strong names

Hi, Michael. I decided to try your library by installing it through NuGet Package. But, unfortunately, Visual Studio said that the library is not signed with a strong name. My programs are all signed, and the Studio requires that all libraries referenced in my project were also signed. It is very easy using the project properties within Visual Studio.
https://msdn.microsoft.com/library/ms182127.aspx

p.s.: sorry for my bad English, it's not my native language.

Unable to run compiled application on linux

Hello,

I have attempted to get a compiled server executable to run on linux but I keep getting Unhandled Exceptions. I am compiling in VS2013/VS2015 on Win8.1x64

I have not been able to get even the included samples to run on my Debian 8 box, executing for instance the "EncryptionSample/EncryptionServer.exe" I get the following:

Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
at System.Net.NetworkInformation.NetworkInterfaceFactory+LinuxNetworkInterfaceAPI.GetNetMask (System.Net.IPAddress address) <0x41c958b0 + 0x00017> in <filename unknown>:0
at System.Net.NetworkInformation.NetworkInterface.GetNetMask (System.Net.IPAddress address) <0x41c95880 + 0x0001c> in <filename unknown>:0
at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () <0x41c957d0 + 0x00043> in <filename unknown>:0
at Lidgren.Network.NetUtility.GetBroadcastAddress () <0x41c6d870 + 0x000f6> in <filename unknown>:0
at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) <0x41c6d4d0 + 0x0015b> in <filename unknown>:0
at EncryptionServer.Program.Main (System.String[] args) <0x41c6ad50 + 0x0004f> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The method or operation is not implemented.
at System.Net.NetworkInformation.NetworkInterfaceFactory+LinuxNetworkInterfaceAPI.GetNetMask (System.Net.IPAddress address) <0x41c958b0 + 0x00017> in <filename unknown>:0
at System.Net.NetworkInformation.NetworkInterface.GetNetMask (System.Net.IPAddress address) <0x41c95880 + 0x0001c> in <filename unknown>:0
at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () <0x41c957d0 + 0x00043> in <filename unknown>:0
at Lidgren.Network.NetUtility.GetBroadcastAddress () <0x41c6d870 + 0x000f6> in <filename unknown>:0
at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) <0x41c6d4d0 + 0x0015b> in <filename unknown>:0
at EncryptionServer.Program.Main (System.String[] args) <0x41c6ad50 + 0x0004f> in <filename unknown>:0

I saw another issue posting here that stated to include __CONSTRAINED__ in the defined symbols field, which causes the compiler to use PlatformConstrained.cs instead of PlatformWin32.cs, when applying this change my error changes to:

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.MWCRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetUtility' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Lidgren.Network.NetUtility..cctor () <0x4080ea90 + 0x00085> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandomSeed.GetUInt64 () <0x4080b230 + 0x000f7> in <filename unknown>:0
at Lidgren.Network.NetRandomSeed.GetUInt32 () <0x4080b1f0 + 0x0000b> in <filename unknown>:0
at Lidgren.Network.NetRandom..ctor () <0x4080afc0 + 0x0001f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..ctor () <0x4080af30 + 0x0000f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..cctor () <0x4080af80 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandom..cctor () <0x4080ad50 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.MWCRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetUtility' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Lidgren.Network.NetUtility..cctor () <0x4080ea90 + 0x00085> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandomSeed.GetUInt64 () <0x4080b230 + 0x000f7> in <filename unknown>:0
at Lidgren.Network.NetRandomSeed.GetUInt32 () <0x4080b1f0 + 0x0000b> in <filename unknown>:0
at Lidgren.Network.NetRandom..ctor () <0x4080afc0 + 0x0001f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..ctor () <0x4080af30 + 0x0000f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..cctor () <0x4080af80 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandom..cctor () <0x4080ad50 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---

I see it mentioning MWCRandom inside NetRandom, the only line I can find referencing that is:
public static NetRandom Instance = new MWCRandom();

I'm unsure how to proceed further as my internet research does not pull up much on the way of MWC.

Leaving out __CONSTRAINED__, I am able to run the executables in Windows without any issue.
I am using the mono-complete package v4.2.1 on my linux box.

Any help is appreciated, Thanks.

Random Connection Timed Out

We have a Unity PS4 game with a Lidgren networking back-end for both server and client. However, for some reason, clients will get disconnected for seemingly no reason. The only indication of anything going wrong is the StatusChange message saying the connection timed out. We have already tried adjusting the time out lengths on both server and client. Actually, sometimes the time outs seem to occur before the time out period has even passed. It happens regardless of server load; and also, we see the same thing when connecting to our server through gigabit LAN. So, it doesn't seem like there is actually a time out going on... But we are totally at a loss. We don't really know what else to do. Any help in figuring this out would be greatly appreciated.

Unity3D, uses classes not provided by unity .net version??

Apparently this program uses AesCryptoServiceProvider in NetAESEncryption. I've read somewhere that apparently System.Security.Cryptography.RijndaelManaged is kind of a replacement class for it however I would like for this to be verified. I don't plan on using cryptographic functions for this so for now I'm just going to implement it. Is there something else that I should be doing here that wasn't listed in the wiki?

NetBitWriter.ReadByte NullReferenceException

occasionally, NetBuffer.ReadByte is throwing a nullreference on what appears to be a perfectly valid message.

nullref

As in the image, the buffer has data (and not visible, but the position is 0), but a nullref is being thrown from NetBitWriter.

built straight from c42b885

Remote Procedure Call update proposal

Hello.

I have developed a simple RPC library using my beloved Lidgren.Network, and I would like to present what I have achived during the last days.

Here I post link to an image: http://i.snag.gy/EBXXY.jpg (code inside)

Now, I'm not that strong with English language, please excuse me if I'm being not clear at some points and feel free to ask for clarifications.

In short:

  1. The project I made allows the user to transfer procedure calls over the UDP connection. Any side (client or server) can make a call to a method (with parameters, or course) of an interface and the code will be executed on the remote side.
  2. The workflow is pretty straightforward: you create a NetOutgoingMessage, set it as the RPC's wrapper's target, make a call to the RPC's interface (created via dynamic proxy of Castle.Core package), and then you send the message. On a receiver's side you read a NetIncomingMessage, throw it at the RPC's unwrapper and process the method invocation at your defined class.
  3. The RPC library allows you to customize the way an argument wraps into a message (and unwraps out from one).
  4. All the calls are made by open delegates and therefore much faster than the pure reflection invocations.
  5. The wrapper and unwrapper are built only once and can be used as long as it needs to be.
  6. .NET is 3.5 (Unity3D friendly), the Castle.Core NuGet package is referenced inside.
  7. out, ref parameters and non-void return types are not supported, I hope you understand why.
  8. I'm planning to make the RPC library support the interface's properties so that they could be kept up-to-date, creating the binding-over-udp.

My question is, will there be any interest in this? I'm planning to use this in my game, as I see much necessity of it in there. Could this be merged? If not, do you, @lidgren allow me to create a nuget package which would use your library?

NAT punch isn't working on 4G

NAT punch works fine on Wifi
(I've tried both Peers behind Different NATs and
Peers behind the Same NAT conditions)
But it doesn't work on 4G.
Would anyone help me out here

I use the lidgren Mac 5.1.2 unity platform has been a problem

Error]:Exception:{0}
{1}This platform is not supported at System.Collections.Generic.RBTree..ctor (System.Object hlp) [0x00000] in :0
at System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties () [0x00000] in :0
at Lidgren.Network.NetUtility.GetNetworkInterface () [0x00000] in :0
at Lidgren.Network.NetUtility.GetBroadcastAddress () [0x00000] in :0
at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) [0x00000] in :0
at DashFire.Network.NetworkSystem.Init () [0x00000] in :0
at DashFire.GameControler.InitLogic () [0x00000] in :0
at GameLogic.StartLogic () [0x00000] in :0
at GameLogic+c__Iterator25.MoveNext () [0x00000] in :0

Unity.Network.externalIP

Hi,

I have been using unity for the past 5 years and noticed in your library with NetUtility.GetIPAddress your assuming that Unity.Network.externalIP will resolve but it wont I have a solution but I am not going to try and botch your code up.. This example will help to get the external IP from unity..

    private string externalIP;
    private string internalIP;

    private void Start()
    {
        StartCoroutine(NetworkSetup());
    }
    public IEnumerator NetworkSetup()
    {
        Network.Connect("127.0.0.1");

        while (Network.player.externalIP == "UNASSIGNED_SYSTEM_ADDRESS")
        {
            time += Time.deltaTime + 0.01f;

            if (time > 10)
            {
                Debug.LogError(" Unable to obtain external ip: Are you sure your connected to the internet");
            }

            yield return null;
        }

        internalIP = Network.player.ipAddress;
        externalIP = Network.player.externalIP;
        Network.Disconnect();
    }

reference is
///


/// Gets my local IPv4 address (not necessarily external) and subnet mask
///

public static IPAddress GetMyAddress(out IPAddress mask)
{
mask = null;
#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS || UNITY
try
{
if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable))
{
return null;
}
return IPAddress.Parse(UnityEngine.Network.player.externalIP);
}
catch // Catch Access Denied errors
{
return null;
}
#endif
return null;
}

The method NetworkSetup might look weird as Unity decided to make it some what like a thread. Just think of the method as a thread :). I start off by connecting to myself and loop through while until the address is found or 10 seconds has passed. If everything was successful it will return the externalIP else log as Unable to obtain external ip. You have to make sure to make a connection first before getting the externalIP sort of shitty but that's how unity engineered it.

Best Regards
Levon Ravel,

Lidgren built with mono fails on Linux

Hi Lidgren,

We're encountering an issue in the startup of a server with the newest version of Lidgren here from Github. The file is built with mono and is therefore an .exe file, but it is supposed to run on a Linux platform (we know this worked before).

It appears now, probably due to the recent updates, that GetBroadcastAddress is attempting to call a Linux specific method implementation, which does not exist in Mono where it should probably be using the Windows equivalent. At least that is my guess.

The error message is as follows:

Unhandled Exception: System.NotImplementedException: The requested feature is not implemented.
 at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetUtility.GetBroadcastAddress () [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) [0x00000] in <filename unknown>:0
  at Lobby.Server.LobbyServer..ctor () [0x00000] in <filename unknown>:0
  at Lobby.Server.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The requested feature is not implemented.
  at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetUtility.GetBroadcastAddress () [0x00000] in <filename unknown>:0
  at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) [0x00000] in <filename unknown>:0
  at Lobby.Server.LobbyServer..ctor () [0x00000] in <filename unknown>:0
  at Lobby.Server.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

Hoping that a speedy solution can be found so we may continue using your excellent library.

Thanks in advance.

IPv6 support

Google Code Issue 175: IPv6 support

I have modified the library to support IPv6 dual mode by changing the socket configuration and by mapping any IPv4 addresses handled to the Connect- and ActuallySendPacket-methods to IPv6 addresses using NetAddress.MapToIPv6(). I have also changed the the default LocalAddress to IPAddress.IPv6Any and have modified the NetUtility.Resolve to also resolve IPv6 addresses.

All unit tests pass and I can connect to a NetServer with LocalAddress = IPAddress.IPv6Any by using an IPv4 address (e.g. 127.0.0.1) as well as an IPv6 address (e.g. ::1).

The biggest "drawback" with this implementation is that internally all addresses are handled as IPv6 addresses. This is especially apparent when it comes to debug output; you will see lines like:

Socket bound to [::ffff:127.0.0.1]:53662: True

I'm new to collaborating via GitHub, but if you are interested in applying the changes I could probably figure out a way to create a pull request :)

Can't connect to different ports.

What is the correct way to connect to different ports of the server if one port is not available because of the LAN settings?

I have server started on two ports. Connecting to first port if available is successed, but if first port not available, I can't connect to other. Connect to second port on start is also successed.

When I connecting to first port, I receive status Disconnected with message: Failed to establish connection - no response from remote host.
When I connecting to second port, I receive status Disconnected with empty message.

What I tried: just second call Connect to new port; Shoutdown NetClient and create new. Same results.

I'am using Unity.

Delay

I'm writing a server and a client.

Each client, sends a NetOutgoingMessage every 50 ms, that's equal to 20 messages per second. This message cointains 4 variables, which represent the current player's position and rotation.

The server, after receiving this message, calculates the next position of the player, then sends it back to all connected players from that match, using the following line:

> server.SendMessage(outMessage, connectionsList, NetDeliveryMethod.Unreliable, 0);

(connectionsList is a list of NetConnection objects, not an array)

Also, the server constantly sends an update of the current position of another object, a ball, every 30 ms; that's equal to 33 times per second. The message is sent by a separate thread.

The problem is:

I get severe delay when running over 3 instances of the client on the same machine, or a different machine in the local network. It looks like the network messages are getting stuck in a stack of messages, because even after I close the other clients, the messages from those disconnected clients take too long to arrive at the client that's still running.

Are the messages being sent too frequently? What's going on?

(I'm using the latest version of the library, and coding the client on Unity)

Instability (resolved)

Hello!
It seems after commit fa8b1e9 the library is working very unstable for us - the connection is dropped very often and latency increases very high after some time.
Have to revert on previous commit to fix that.
Regards!

Slow connection file Transfer does not arrive unless NetPeerConfiguration.AutoExpandMTU = true;

Hello,

I'm using Lidgren the primary networking component in one of my projects. Im trying file transfer with the libary and noticed that "larger" packages do not arrive at the other end when being transfered over a slow connection, unless the Setting AutoExpandMTU is enabled.

Ive tried it a dozen times with both the setting disabled and enabled and always only received the package from Lidgren at the other end when the setting is enabled.

The specific data where talking about is a 512 KB textfile and a maximum 100 kb/s upload rate.
I also noticed that this data is send twice by the netserver, meaning that I am monitoring a transmition of about an entire megabyte instead of just approx. 512 kb which I would expect.

Did anyone ever had transmission problems with large data?

Greetings,

SonicTTH

What is the status of SRP???

I have been tinkering around with lidgren for a couple of days now. Congrats on the great work!

I have a question though.

How would I go about creating user authentication? I came across SRP in this repo https://github.com/SleeplessByte/lidgren-srp6a which is based on a single argument ctor of NetXTEA class and as such not compatible.

I can see the NetSRP class in the latest lidgren repo though but no samples?

Thank you in advance :)

Connecting multiple clients to a single server on same machine

I'm having multiple connections from the same machine to itself.

I'm creating a peer-to-peer network and I introduce every body correctly and they are all connected to each other (netPeer.Connections has the correct amount or connections and they are all connected).

When I try to send a message outward, only 2 of the peers (out of 4) are able to send.

Is there a problem where they get mixed up?

Target .NET Core

.NET Core is new from Microsoft's new cross-platform solution to support Linux/Mac/Windows. It would be great if this library could be used in that platform.

NuGet package

Any chance of a NuGet package? Would make life 10x easier!

Android/iOS support with Unity

So recently I came across with an annoying incompatibility:
I can't use the library with Unity Engine to build an Android game.

I can't add the reference to Mono.Android because it requires a higher framework version than the mono 3.5 and unfortunately unity only support up to mono 3.5 as far I know.

Do someone know how to fix this and use Lidgren with Unity and Android/iOS?

NetConnection.m_sentPingTime

In the class NetConnection, the variable m_sentPingTime receives a value at InitializePing() that SendPing() overwritten a little after without being readed.

What was the intention of this lines?

// randomize ping sent time (0.25 - 1.0 x ping interval)
m_sentPingTime = now;
m_sentPingTime -= (m_peerConfiguration.PingInterval * 0.25f); // delay ping for a little while
m_sentPingTime -= (MWCRandom.Instance.NextSingle() * (m_peerConfiguration.PingInterval * 0.75f));

Thank you

Unity3D, Unable to open dll?

After following the wiki and getting the build completed. I put the dll, xml, and pdb files along with the license into the folder "Assets/Assemblies/Lidgren". For some reason Unity is giving me the error "Unable to open Assets/Assemblies/Lidgren/Lidgren.Network.dll: Check external application preferences."
I've checked everything 3 times to make sure that I was doing it right. I should note that I'm using Unity 5.5.5f1.

Possible client send to all or read random incoming messages?

Hey I am working with unity 3d.
I try to make a framework where clients later can send messages with random sizes.. so you can write float int, int... or int, float, int if you want.

How is possible to handle it via server. I don't know how I can read incoming message with random stuff or can I forward to all OTHER clients form a client (which goes through the server)?
I want to make the server possible to use like a relay server.

llvm optimization

If I compile a project using Xamarin with llvm optimizations turned on, I would find that I would be unable to establish a connection with a server. This would manifest itself by the client sending a connection request to the server, but the server would complain that it would timeout because it was never able to reach the client.

The llvm optimizations were only being applied to the client. And this is definitely the switch that would determine whether or not the library would work as expected.

Hail message inconsistency

I have clients connecting with a hail message, and it doesn't work sometimes.

Most clients appear to be working, but occasionally I'll get a client that simply doesn't have the hail message

Here is an example of one time that it didn't

bad hailing

If I attempt to use connection approval (turning on the message, and handling it), a similar thing will happen. Sometimes it appears that the hail message is packets from other clients, other times I'm not sure what it is.

simply reading messages like this:

var readMessages = new List<NetIncomingMessage>();
while (true)
{
  var read = _server.ReadMessages(readMessages);
  for (int i = 0; i < read; i++)
  {
    var msg = readMessages[i];
     //do stuff with the message
  }
}

This usually happens if I have other clients already connected and sending data.

Solution setup to compile for different platforms

Grats for this library, I just started using it and i've implemented a framework upon that to use interfaces and reflection magic / compiled expressions to handle my messages without having to do huge switches, etc.. and it works like a charm

Now i moved to Unity because i wanted to play with it, creating a simple project to test my implementation, I successfully built lindgren sources using the info on the Wiki https://github.com/lidgren/lidgren-network-gen3/wiki/Unity3D but ... what if instead polluting code with defines and having to add compilation symbols, you don't take the "Shared Project" route?

In case you don't know, it's a special kind of project in Visual Studio 2015 that doesn't produce any output per se, but is a placeholder to put a code that can be included in other projects, so you can put there partial classes and implement the platform specific code in other projects that compile output for that platform (so you can have a lidgren compiled for unity, one for windows, one for PCL and so on in a single step)

This means to not having to change any code, and no duplication code needed

In order to not generate compilation error in case you don't have some dll (like unity) in your environment, you can just create ad hoc Build configurations that switch off/on the projects you want (so you can have a build like "Debug Unity" that just compile the unity projects, etc...

If you like the idea and don't have the time i could implement the needed changes in my fork when i have the time

cheers

Issue with AutoFlushSendQueue

When AutoFlushSendQueue is enabled: heartbeat() enumerates all channels on all connections and causes a lot of trashing causing problems if a peer have more than ~60 connections

Outgoing message pooling

We're using Lidgren under Unity with message / storage pooling enabled. I would assume that this would cause Lidgren to re-use outgoing messages so that after a short time, there are no more allocations, but that doesn't appear to be the case. Some messages, at least, are getting recycled, but apparently not all of them, because over time GetStorage() continues to allocate new buffers and m_bytesAllocated grows larger and larger. If I put simple tracking inside GetStorage() and Recycle(), over time the number of GetStorage() calls exceed Recycle().

I've put a breakpoint where Recycle() checks for fragments, and that's not getting hit. Do you have any ideas for how we can reduce our memory allocations using Lidgren?

NullRefenceException during DestoreMessage() call

Hello!

I've noticed a lot of exception related to DestoreMessage() call:

private void DestoreMessage(double now, int storeIndex, out bool resetTimeout)
        {
            // reset timeout if we receive ack within kThreshold of sending it
            const double kThreshold = 2.0;
            var srm = m_storedMessages[storeIndex];
            resetTimeout = (srm.NumSent == 1) && (now - srm.LastSent < kThreshold);

            var storedMessage = srm.Message;

            // on each destore; reduce recyclingcount so that when all instances are destored, the outgoing message can be recycled
            Interlocked.Decrement(ref storedMessage.m_recyclingCount);

In my case storedMessage is null.

The problem appeared a few month ago (after I pulled latest commits). Currently I'm using latest version - and exception happens very often when the network clients suddenly disconnects from the server.

Regards!

Specifying a channel for non-sequenced Unreliable command will make it UnreliableSequenced

Hello,
in RELEASE build there is no assert that non-zero channel must be used for Unreliable command (there is such assert in DEBUG build). It passes this assert and then something bad (IMHO) happens - the channel number added to this enum entry at NetConnection.EnqueueMessage() and it becomes UnreliableSequenced. For me, it was a surprising behavior (I found it out only now, three years after release of my product! And it was in critical part of code which expects to work as Unreliable, not as UnreliableSequenced).

I would prefer if in RELEASE build there will be this code:

if (method == NetDeliveryMethod.Unreliable)
{
    sequenceChannel = 0;
}

in both the NetPeer.SendMessage() methods.
(throwing exception in DEBUG build is ok).

Also I found quite misleading this statement:

Duplicate packets detected and dropped for all delivery methods (even unreliable)

(from https://github.com/lidgren/lidgren-network-gen3/wiki/Features )
I checked the code and it seems there are no duplicate detection for completely Unreliable messages, only for UnreliableSequenced. Will you update the wiki or code accordingly?

Crash because SHA256 is not FIPS-compliant

Hello!
One of our users reported that the application is not working for him because of this exception in Lidgren network library:
System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
at System.Security.Cryptography.SHA256.Create()
at Lidgren.Network.NetUtility..cctor()

It seems he has a security policy enforced to allow only FIPS-compliant crypto-providers:
http://blog.aggregatedintelligence.com/2007/10/fips-validated-cryptographic-algorithms.html

var setMethod = fi.SetMethod;

There seems to be a problem in Netbuffer.Read.Reflection and Netbuffer.Write.Reflection.
at line 99 code: var setMethod = fi.SetMethod;

Error:
Error 1 'System.Reflection.PropertyInfo' does not contain a definition for 'SetMethod' and no extension method 'SetMethod' accepting a first argument of type 'System.Reflection.PropertyInfo' could be found (are you missing a using directive or an assembly reference?)

I'm on Windows 8.1
Visual Studio 2013, Unity 5.

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.