• 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
Question by MLM · Jan 20, 2014 at 06:47 AM · networkingnetworkserverconnectpassword

Network.Connect() never returns InvalidPassword

Whenever `Network.Connect` is called with the wrong password provided, the returned `NetworkConnectionError` is NetworkConnectionError.NoError. And then in the Unity Console it displays these two errors:

  • "The remote system is using a password and has refused our connection because we did not set the correct password."

  • "The connection request to 192.168.1.200:25001 failed. Are you sure the server can be connected to?"

  • Unity Console Window displaying errors

The returned value should be NetworkConnectionError.InvalidPassword so that I can deal with the mistake. The Unity errors shouldn't even be happening.

I am using the Network.Connect(guid, pw) version to connect. If you provide the right password or set the server not to have a password, then everyt$$anonymous$$ng works fine. I am testing on the same mac$$anonymous$$ne with a Build & Run instance and one in the Unity editor.

Update: I just tested with two builds just to rule it out and it has the the same result.

 NetworkConnectionError connectError = Network.Connect(guid, pw);
 
 if(connectError == NetworkConnectionError.NoError)
 {
     Debug.Log("Connected to Server"); // Always called even if the wrong password is provided.
 }
 else if(connectError == NetworkConnectionError.InvalidPassword)
 {
     Debug.Log("Invalid Password. Could not connect to server"); // Never gets called
 }


What the heck is going on?

Comment
dscroggi

People who like this

1 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by MLM · Feb 02, 2014 at 05:48 AM

The problem is that `Network.Connect()` gives you the errors asynchronously. The only `NetworkConnectionError`'s returned are those that are immediate such as:

  • NetworkConnectionError.IncorrectParameters

  • NetworkConnectionError.EmptyConnectTarget

T$$anonymous$$s means that you will not only NOT see any of the other errors including NetworkConnectionError.InvalidPassword when calling Network.Connect().

To actually see if you entered an invalid password or any of the other multitude of errors you need to wait for `Network.OnFailedToConnect()`. Or `Network.OnConnectedToServer()` meaning there were no errors and you were able to connect.

Here is a small script to get you started with error handling:

 void OnConnectedToServer() {
     Debug.Log("Connected to server");
 }
 
 void OnFailedToConnect(NetworkConnectionError error) {
     Debug.Log("Could not connect to server: " + error);
 
     if(error = NetworkConnectionError.InvalidPassword)
         Debug.Log("Invalid Password Entered");
     else
         Debug.Log("Another error occured");
 }
Comment
wolfpack4417

People who like this

1 Show 1 · 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 koboldskeep · Oct 02, 2014 at 09:01 PM 0
Share

Good answer. :)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

How can i get real "extern" IP address ? 2 Answers

Connect to remote private IP 1 Answer

OnConnectedToServer not called when testing on same machine 0 Answers

Dedicated server-client networking design (MOBA-like) 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