Jump to content

  • Log In with Google      Sign In   
  • Create Account


Unity3d Basic Networking Issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 kryotech   Members   -  Reputation: 856

Like
0Likes
Like

Posted 31 January 2013 - 06:42 PM

So I've been trying to connect a client to a server in Unity3d. When the client tries to connect to the server, after some time, an error comes up that the system is already connected. I'm not entirely sure what could cause this. Any help? Thanks in advance.


Kryotech

Sponsor:

#2 Casey Hardman   Crossbones+   -  Reputation: 2185

Like
1Likes
Like

Posted 31 January 2013 - 08:03 PM

Are you trying to connect more than once?  That could happen if the call to Network.Connect() is inside an Update() function.

 

To see if you've made a connection already, try this:

 

UnityScript:

function OnConnectedToServer() //This is called when you successfully connect with the server
{
   Debug.Log("Connected to the server.");
}

 

 

C#:

void OnConnectedToServer()
{
  Debug.Log("Connected to server.");
}

 

 

Then you'll be able to tell in the Console window if you've made a connection already.

Alternatively, when you call Network.Connect(), you could put a Debug.Log("Attempting to connect to the server"); before it.  If you see it more than once, then you know something's wrong.



#3 kryotech   Members   -  Reputation: 856

Like
0Likes
Like

Posted 31 January 2013 - 08:42 PM

That's actually the issue, the console never shows a successful connection...and I tried checking within a OnConnectedToServer function as well, but it seems that client never connects...

 

EDIT:

 

Also, run in background is enabled, so that's not interfering either...


Edited by kryotech, 31 January 2013 - 08:46 PM.

Kryotech

#4 Casey Hardman   Crossbones+   -  Reputation: 2185

Like
0Likes
Like

Posted 31 January 2013 - 10:03 PM

That's odd...

 

You're calling Network.InitializeServer() on the server and Network.Connect() on the client, both using the same port, right?  Are they both running separate Unity projects (e.g. OnlineGameClient project is trying to connect to OnlineGameServer)?  Or are you trying to make a game where a certain player hosts the game for other players, like Warcraft III, instead of using a dedicated server?

 

The issue could be related to the port number you're using with Network.Connect().  Have you tried changing it yet?  If you are, remember to change the port of InitializeServer() AND Connect() to the same value.

 

If you still can't get it to work, please post the code you're using to Connect() and InitializeServer(), and the full error message you're getting in the Console (you can copy from the Console with CTRL+C and paste here).


Edited by Sir Mac Jefferson, 31 January 2013 - 10:03 PM.


#5 kryotech   Members   -  Reputation: 856

Like
0Likes
Like

Posted 01 February 2013 - 06:36 AM

The program is really just a simple connect to the server program, where one project hosts and the other tries to connect. I tried doing separate projects as well, and the eror that comes up is that the client is banned from connecting. I have not tried changing the port number yet, so maybe that will make a difference.


Kryotech

#6 kryotech   Members   -  Reputation: 856

Like
0Likes
Like

Posted 03 February 2013 - 07:11 AM

Alright, I figured it out, the Network.InitializeServer was being called over and over again. So I got the system to connect, but it only connects to my computer on the local network. Why would the system be unable to connect from a different network? Thanks in advance for any help.


Kryotech




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS