lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

Unity 2019.4 LTS: calling client.Connect gives SocketException Invalid arguments immediately #142

Open miwarnec opened 4 years ago

miwarnec commented 4 years ago

Hey guys, when using Lidgren master in Unity 2019.4 LTS I get the following error when calling client.Connect:

"Failed to send packet: System.Net.Sockets.SocketException (0x80004005): Invalid arguments 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 :0 at Lidgren.Network.NetPeer.ActuallySendPacket (System.Byte[] data, System.Int32 numBytes, System.Net.IPEndPoint target, System.Boolean& connectionReset) [0x000bc] in /Users/qwerty/x/dev/project_DOTSNET/RepositoryDOTS/Assets/DOTSNET/Scripts/ECS/Transport/Transports/Lidgren/Lidgren_2020-07-13/NetPeer.LatencySimulation.cs:164 "

It happens both when a server is running, and when a server isn't running.

I dropped Lidgren in as source code, not as DLL.

Anyone knows what might be causing this? I can't be the only one using Lidgren in Unity?

Thanks :)

miwarnec commented 4 years ago

Here is the line that causes it: 2020-07-13_18-30-14

Here is the data that is being passed: 2020-07-13_18-30-02

miwarnec commented 4 years ago

Note that the error is in LatencySimulation.cs - I didn't turn on latency simulation though. Unless that's enabled by default, but why would it?

miwarnec commented 4 years ago

Checking LatencySimulation.cs: looks like #if DEBUG is enabled in Unity editor. I removed that #if DEBUG part so it uses regular send. Still get the same error though.