Comments (10)
The code below definitely fires on both clients but I don't get any messages after that and when I check netPeer.Connections it's still at "1" which is the connection to the master server.
case NetIncomingMessageType.NatIntroductionSuccess:
Debug.Log("Nat: " + msg.SenderEndPoint.ToString() + " : " + this.GetHashCode());
netPeer.Connect(msg.SenderEndPoint);
Debug.Log(netPeer.Connections.Count);
from lidgren-network-gen3.
Did you set NetPeerConfiguration.AcceptIncomingConnections to true for each of those peers? I forgot it when I evaluated this library a few days ago :)
from lidgren-network-gen3.
Yes, this is my config:
config.PingInterval = 0.5f;
config.ConnectionTimeout = 5;
config.MaximumConnections = 32;
config.AcceptIncomingConnections = true;
config.AutoFlushSendQueue = true;
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
from lidgren-network-gen3.
I've had it randomly work twice. I get these each time though:
NAT punch received from 127.0.0.1:57754 we're client, so we've succeeded - token is MatchMaking
NAT punch received from 192.168.1.2:57754 we're host, so we ignore this
I'm guessing the NAT punch is really successful enough.
from lidgren-network-gen3.
I tried the master server sample and it still doesn't make the connection.
m_client.Connections.Count = 0 in the MSCLIENT after a NatIntroductionSuccess
from lidgren-network-gen3.
Just to add to this, I'm spawning 2 NetPeers and having them connect to a master server. I'm assuming I can do this and have those two peers make connections to each other.
Any help would be appreciated as I'm still pretty stuck.
from lidgren-network-gen3.
I'll can try to run the same example when I'm at home - what's your setup? Are the peers and master server on the same computer or different ones?
from lidgren-network-gen3.
All on same PC.
Master seperate process
Client both in same process as seperate objects
from lidgren-network-gen3.
Ok, I turned off UPnP on my router and now get the error below, what's interesting is that I turned UPnP back on then used DiscoverKnownPeer after a NatIntroductionSuccess message and connected on a DiscoveryResponse message and I get the same message.
I assume this is a good message and it's actually trying to connect but it has issues adding with the m_handshakes collection, adding to it from a different thread or something.
System.InvalidOperationException: out of sync
at System.Collections.Generic.Dictionary2+Enumerator[System.Net.IPEndPoint,Lidgren.Network.NetConnection].VerifyState () [0x00028] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:912 at System.Collections.Generic.Dictionary
2+Enumerator[System.Net.IPEndPoint,Lidgren.Network.NetConnection].MoveNext () [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:835
at Lidgren.Network.NetPeer.Heartbeat () [0x000c0] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\NetPeer.Internal.cs:322
at Lidgren.Network.NetPeer.NetworkLoop () [0x00000] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\NetPeer.Internal.cs:208
UnityEngine.Debug:Log(Object)
Lidgren.MatchMaking.c__Iterator0:MoveNext() (at Assets/Lidgren.MM/MatchMaking.cs:164)
from lidgren-network-gen3.
Ok, I figured out what I was doing wrong.
My master server was trying to Introduce both sides Introduce(A,B) then Introduce(B,A).
And it was also doubling up the introductions. It connects everytime now, sometimes it produces an out of sync error but it still seems to connect the peers successfully.
I've kept the DiscoverKnownPeer as that seems to work when UPnP is enabled or disabled.
Close this issue.
from lidgren-network-gen3.
Related Issues (20)
- ReceivedPong doesn't consider late/not in order pong messages HOT 8
- Incorrect network messages/malformed packets could easily overwhelm the server HOT 2
- Cannot Reconnect
- Example Code from Basics doesn't yield same results HOT 1
- Trying to compile for Android HOT 2
- Accepting connection does not increase ConnectionsCount? HOT 1
- Is there a possibility to modify lidgren to support DTLS??
- [QUESTION] Thread safety HOT 5
- Unity 2019.4 LTS: calling client.Connect gives SocketException Invalid arguments immediately HOT 3
- Active forks? HOT 13
- Large unreliable message cannot be sent properly HOT 2
- Might want to lock stuff here? HOT 2
- The examples client gives error when trying to connect to server form second VS
- Unity network
- Is it possible to send and receive structs instead of classes ? HOT 1
- Is it still possible to build for Unity? HOT 3
- NetQueue concurrency HOT 2
- ICMP Destination unreachable (port unreachable) won't close connection HOT 1
- Server can't receive connection HOT 1
- Lidgren.Network.NetException: This message has already been sent! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lidgren-network-gen3.