Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BenouKat · Jan 28, 2013 at 01:11 PM · networkserverclientconnectionnat

How connect client to server when ip is private ?

I'm a bit beginner in Unity networking (and networking...).

I have a server and a client, i want to my client connect to the server through internet (no local adresses so.).

I initialize my server with Network.InitializeServer(), and put useNat to true because the function HavePublicAdress() return me "false".

I connect my client with Network.Connect(), and put the externalIP and externalPort value of my server in parameters of this function.

My server starts okay, but for my client Unity said "The connection request failed", and the TestConnection() function return me "LimitedNATPunchtroughPortRestricted".

Did i miss something ? I think it's because of my private ip adress, but how to connect in this case ?

Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Dreamora · Jan 28, 2013 at 01:56 PM

You need to make it connect to a master server after initializing the server as you need NAT PunchThrough to connect from the outside, as this is handled and routed through the master server.

Without a master server you will have to force everyone who hosts games to setup UDP portforwards on his router and firewall.

A word of warning on this though: do better not rely on the inbuilt default addresses for masterserver, nat facilitator and connection tester as especially the nat facilitation on the UT servers are often not reachable and working. Also they are not for production use in any form so sooner or later you will be required to handle this yourself in some form.

The manual part of the documentation contains further information on the matter of the master server

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BenouKat · Jan 28, 2013 at 06:19 PM 0
Share

Arggh... i was a bit afraid of "$$anonymous$$aster server" solution.

The fact is, i cant make my own master server (don't have the possibility), i dont want to pay a server and after all, i don't want this kind of "functionality" for the multiplayer part.

If i tell you that configure port into router and firewall is not a problem ? $$anonymous$$y goal is to have a system host/client like you can find on $$anonymous$$ecraft. A player host the game, give his ip and port adress to friends, and friends connect to him with his ip and port. No "master server", just a server on hoster machine.

Is there a solution to do this "simply" with my private ip (without master server) ? Or do i $$anonymous$$UST go on public adress for host something ?

avatar image Dreamora · Jan 29, 2013 at 09:21 AM 1
Share

In that case its no problem :) All you need to do is inform the user of the port they must forward (its the one you use to initialize the server) and tell them they need to forward UDP.

And on the client side the user then is required to provide the IP manually.

Technically if the hosters are required to port forward you could use a free website system and write a 'game listing service' using php on the server and WWW in unity to make games listable again without any cost involved.

avatar image BenouKat · Jan 29, 2013 at 03:28 PM 0
Share

Perfect thank you :) I guess my problem of "connection failed" is due to a closed port on my router so.

Thanks for your help :)

avatar image
0

Answer by qabal · Dec 21, 2016 at 02:14 PM

"Without a master server you will have to force everyone who hosts games to setup UDP portforwards on his router and firewall" ...which still may not work because of your internet-provider NAT. So, even if you're writing simple two-person chat software you still need an outer server.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Client connects to server, but Network.peerType returns Disconnected until next click 2 Answers

Server initialization not accepting connections. 0 Answers

Is there a way to notify to the app once client has connected to server? 2 Answers

Connect to remote private IP 1 Answer

Networking UNet: Why can we have multiple NetworkClient and how NetworkBehaviour knows which one to use? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges