RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3.09k stars 499 forks source link

Hole punching not working while both peers are behind different NAt #51

Closed abunoman2003 closed 6 years ago

abunoman2003 commented 7 years ago

Hole punching for different NAT's peers not successful. I have tried windows firewall to accept incoming connections too. Any help will be appreciated.

Thanks

RevenantX commented 7 years ago

Hi! Can you give more information? Minimal working code and your connection scheme.

abunoman2003 commented 7 years ago

Hi! Thanks for your reply. I am using the code as is in sample. Just separated for server and Client Side, also i converted the codes for vb.net. Please check as attached ClientSideCode.txt ServerSideCode.txt

Thanks once again!

RevenantX commented 7 years ago

@abunoman2003 Where you host server? Server must be hosted without NAT (or with forwarderd ports).

abunoman2003 commented 7 years ago

its VPS, Sure, Server without NAT (Directly public IP and all incoming and outgoing ports are allowed in firewall). Also have tried with another server with port forwarded with no luck

abunoman2003 commented 7 years ago

If both Peers are in same host, in Same LAN (Same NAT), or Any one peer is without NAT (directly used public IP, other means Internal Endpoint and External Endpoint is Same) then connection is successful between peers with the same server i used. :)

If you have chance to test in your side, would you please advice the way. Minimal code for server and client would be very helpful.

Thanks

RevenantX commented 7 years ago

@abunoman2003 if two peers behind symmetric NAT ( often in offices ) - hole punch will not work. Or you use simple home routers to test?

abunoman2003 commented 7 years ago

Hi! I have tried with different routers too with no success. Thanks

abunoman2003 commented 7 years ago

By the way i can use other P2P applications like Skype, Teamviewer, Ammyy Admin etc whose used hole punching

RevenantX commented 7 years ago

@abunoman2003 skype and teamviewer can work with external server ( if NAT punch fails ). But i will check this problem. (visual basic is hard to read =\ )

timematcher commented 7 years ago

@abunoman2003 Here are your vb code files converted to C# ClientSideCode.txt ServerSideCode.txt

I have not tested the above code. So I have no idea if it compiles or works. For @RevenantX 's review :)

abunoman2003 commented 7 years ago

@timemacher thank you so much.

abunoman2003 commented 7 years ago

@RevenantX Hope you are doing fine. Is there any update?

Thanks

RevenantX commented 7 years ago

@abunoman2003 sorry. I have no time right now (main work). I will look at weekend. Can you send logs (just console output)? From both client and server.

abunoman2003 commented 7 years ago

@RevenantX How are you? Please find the attached project for Server and Client. Sorry for late as i was out of work. 12-06-2017_HolePunching_test.zip

RevenantX commented 7 years ago

@abunoman2003 Hi! Checked your code. All works ( =| ). I think you have router with symmetric NAT (or some blocking mechanism...). There can be IPv6 problem. Can you show server logs (this will be most helpful)?

abunoman2003 commented 7 years ago

You mean debug log? Or please specify, I am sorry. By the way can give me minimal working code to communicate p2p using sever while hole punching failed. Thank you

RevenantX commented 7 years ago

@abunoman2003 just output from server and client. (screenshot of console window) or write logs to file.

abunoman2003 commented 7 years ago

[@RevenantX] hope you are fine. Please find logs attached here for Server and both peer. These days i could not find environment to test. By the way can give me minimal working code to communicate p2p using sever while hole punching failed. Thank you Server Client Log.txt

abunoman2003 commented 7 years ago

@RevenantX
How are you? Any update?

RevenantX commented 7 years ago

@abunoman2003 i will create test project for you to get additional info.

abunoman2003 commented 7 years ago

@RevenantX Thank you. I am waiting for test project.

abunoman2003 commented 7 years ago

@RevenantX How are you? I am still waiting for the Test Project. If you have time please...

RevenantX commented 6 years ago

@abunoman2003 only day ago i found possible place of this behavior. I will try fix) (i know its too late possibly)

abunoman2003 commented 6 years ago

OK, thank you so much in advance

RevenantX commented 6 years ago

@abunoman2003 uploaded some fixes into master branch.