Search Unity

Networking Example could NOT work

Discussion in 'Multiplayer' started by donlien, Apr 13, 2009.

  1. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear friends:

    I am a new guy here.

    There is a big problem to me, and I know this is not a new one question.

    But I still could not find answer here by seraching many subjects. :(

    Please help me!! Thank you for your kindness... :oops:

    I've downloaded the basic network sample here:
    http://unity3d.com/support/resources/example-projects/networking-example

    And my friend and I started it in Unity Windows version without changing anything.

    We've tried hundreds of times, but the sample never work.

    The error message shows in the attached file.

    It said "The connection request to [ip:port] failed. Are you sure the server can be connected to?"

    We just click "play" botton to run it in Unity's editor, one click "Start Server", the other one enter the ip (get it from "ipconfig /all" in windows command line) and click "connect", but it always show the same message, even though we disable firewall.

    And we'd tried every sample in project, included Car racing, castles, chat, Ping test, Third Person, TPS-Auth, but the result were all the same.

    Would you please tell me, how could we make this sample work?

    I've seen there are some threads here mentioned about NAT setting, I've checked it, there is nothing could be set except "address transform (?)" and "delete log".

    Our switch's type is BUFFALO AirStation WHR-G300N.

    So, I don't know what's wrong with NAT? or there is other problem of executing this sample?

    Please help me!!!

    Thank you all!!! :wink:
     

    Attached Files:

  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    unless you have fully setup portforwarding, don't connect to the ip directly but use the master server and NAT punchthrough as UDP connections will otherwise be dropped by your router right off.
    This is assuming that you are at different locations.
    within the same lan, ensure that you don't use the internet ip but your local lan ip for connection and that you have a router to route the message
     
  3. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear dreamora:

    Thank you for your help. :)

    According to your answer, I think I had to make my question and situation more clear. 8)

    We had tested that sample in the LAN environment, and every computer had the fixed ip gotten from the switch.

    This is the simple profile of our running environment:

    2 computers:
    Core 2 Quad CPU Q9400
    8GB, Windows Vista x64 (UAC disabled)
    Nod32 / Avira ad-aware antivirus software

    try to connect each other from those ip:
    192.168.11.20 <-> 192.168.11.30

    2 Com. Direct connect with this Switch in the LAN:
    BUFFALO AirStation WHR-G300N, DHCP Mode, Fixed ip ADSL 8M/640KB.


    We don't have any router standalone, and did not block any protocal such as MSN.

    When the computer which was being client, NOD32 announce a warning at the first time, we choose "Allow connection", and it never come up again.

    We've tried times and times again.

    But, even when we disable NOD32, and disable Windows firewall on the computer which running Avira, they just DIDN'T work.

    "Start Server" side always run immediately, but "connect" side always wait something, and response that failed message.

    Could you please tell me, what's the problem could that be?

    Thank you again. :wink:
     
  4. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    More often than not, Windows Firewall causes issues like this one. Trying turning the Windows Firewall (or any other software firewall you may have running) off and see if that helps.
     
  5. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear CheapDevotion:

    Thank you for your suggestion.

    But we've tried disabled firewall, it still could not run correctly.

    I wonder if there were any easy way to see what happened about Unity network sample?

    Or any debug method?

    Is it possible to run this sample's server and client in the same time on one computer, not 2 or more computer?

    Thanks a lot. :wink:
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Nod32 will disable the windows firewall.

    I've nod32 internet security and no problem with it.
    One thing to check thought is how you set the lan area in the settings / truste zone. ensure to have it set to allow sharing

    Are you sure that the server end has both rights enabled? because the one hosting the server should get asked twice. once for granting network access and once for hosting the server commonly. you can check that in the application list if you enter the firewall settings. it should have UDP receive allow.


    PS: Just to save confusion in the future. What you have is likely either a router or a Wifi Access point. Switches don't hand out IPs (DHCP) and wouldn't allow system system communication potentially.
     
  7. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear dreamora:

    Thank you for reply. :)

    I am sorry for the confusion about access point.

    And I follow your instruction to try again.

    I've done things blow this time:

    1. Disable Whole NOD32. (Client / ip:192.168.11.30)
    2. Disable Whole ad-aware, avira (Server / ip:192.168.11.20)
    3. Start Server with car racing sample.
    4. Start Client with car racing sample, Type 192.168.11.20 in the edit field, port 25001.
    5. Client click connect.
    6. wait for about 10 seconds.

    and the result was the same ERROR....

    I am so sad for that... :cry:

    I wonder, is this problem just because we use the trial version [Version 2.5.0f5 (21627)] for evaluation?

    Could this sample only work on indie or pro version?

    Or, Since the sample is for Version 2.0, so it could NOT work on Version 2.5?

    Does anyone know the answer? Would you please help me?

    Thank you. :?
     
  8. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear All:

    After trying, trying, trying..... again, at last, I've done it!!! :D

    I am so happy to share "a little trick about How to run this sample more easy in LAN" here to save your time (if you are a new one like me ). 8)

    1, download the example and extract it to anywhere you like.

    2, select "open project" on the menu of Unity, and select the directory where did you extract it.

    3, DO NOT be too hurry to run anything which looks cool, but only select one test item such as "test" in the project tab like this:


    4, click "play" on the menu of Unity, you must see menu "Start Server" and "Connect".

    5, Now, carefully at this step... click "Start Server" on both computers of Server and Client, and you must see some warning message which pop up from Firewall software, and you must allow it, and click "Disconnect" menu button on Unity immediately. NOW, you should have see something like this:


    6, And then, click "Retest connection" to clear network state, when it be done, you could click "Start Server" on Server computer, then you will see this server on others computers in the LAN. If you don't see it, please click "Refresh available Servers" on Client computer, and wait for a while, then you will see some server list. (such as [192.168.11.33:25002] in the picture above.)

    7, click "connect" button on client computer, and choose anyone of the game at the bottom of the window of Unity.

    8, If it still could NOT see any server on Client computer(s), please check your firewall setting, you must allow file sharing and allow both directions (in and out) of TCP/UDP's connection of Unity Editor (Unity.exe) on all of the compters, and try again.

    That's all, thank you for reading. :wink:
     

    Attached Files:

  9. oxl

    oxl

    Joined:
    Nov 21, 2008
    Posts:
    325
    Hello,

    just a thought, i see you were trying to connect to port 25001 on your server, but it looks like, it is running on port 25002.

    Maybe this has caused the connection problems ?

    oxl
    --
     
  10. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    yes, you are right.

    This example confuse us (users) with the default value of 25001 filled in the port field when it starts the scene.

    We've tried it again today by change the port value to 25002.... well, today, it seems could work, too. I am not very sure. I've tried it yesterday, but it seems could NOT work. :roll:

    But, I've to say, mmmm.... the developers of Unity had better to change that default value to 25002 to prevent such misunderstanding and be more friendly.

    At least, please remind users about the port value....I've started this thread days ago, and have emphasized that "WITHOUT CHANGING ANYTHING" of this sample, but NO ONE had ever mention about it.

    Although I could find it in the scripts, but, the evaluating time was too short to read every line of tons of the script codes.

    Users have a lots of functions to check for evalution, I think, Unity's team is responsible of such issue.
     
  11. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I never needed to change the port.

    Not even for 2 client - 1 system connections.
    Also the start server part is not required. The test will be executed before you decide what you want to be actually, just wait a moment (first thing I did was add a check that only shows the connect once the tests were done) or click on retest.

    Are you sure you have no service running on that port already?
     
  12. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Dear dreamora:

    Thank you for reply. :)

    First, I could run this sample now.

    And about the port, what I mean is, when that example starts, it shows like this (port No. 25001):



    But, if users "Start Server", it shows like this (port No. 25002):



    well, I am NOT sure if it could work when these two No. were different, but I never could connect to assigned computer with CORRECT IP and port 25001 by just clicking the "connect" button in this menu:

     

    Attached Files:

  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    if the direct connect dialog appears, you just opened the wrong scene.
    The main scene that lets you start one of the different test levels has no direct connect gui.
     
  14. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Okay~~ I am not sure what you say about the "main scene". It seems did not show anything named "main" on the project tab.

    Would you guys be so kind for users to write more explaination in the attached document of that example? or show some directions' pictures? 8)

    Thanks a lot.
     
  15. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    "main scene" just means the scene you have open during debug
     
  16. Thorpedo

    Thorpedo

    Joined:
    Mar 21, 2009
    Posts:
    18
    I think the problem might be that you have two systems confused.

    There are two separate network setup systems in the network example. The first uses the loader scene to set up the network game using the NAT punch through scheme. The second is used if you just run one of the game scenes in the Unity Editor. I had some issues myself when trying to use the scene method in the editor. The problem there is that that system is set up to use port 25000, not 25002 or 25001.

    In the game scene's ConnectGui script (in the DirectConnectGUI gameObject) the following portion determines which one to use:
    function Awake()
    {
    if (FindObjectOfType(ConnectGuiMasterServer))
    this.enabled = false;
    }

    If you want to use the NAT punch through system in the editor you must first load the "loader" scene in the network example and then run from there. I think the other system was a short cut used for testing when the example was created. I use it as a shortcut myself with port 25000 when I'm running two games on the same computer (one in the editor and one in a web browser (after deselecting the other scenes in the build dialog box)).

    It is especially handy when the "Refresh available Servers" button doesn't show any servers even though you are running another instance of one. I sometimes see the other server and sometimes don't seemingly at random. This is perhaps a separate issue with the test server that Unity setup (which is a great service, by the way, when it does work). Sometimes just restarting the game allows the servers to show up. It is frustrating though. Network.natFacilitatorIP: 72.52.207.14:50001 is what I am using (from the example). Any insight into this on again, off again behavior would be appreciated!
     
  17. Tubeliar

    Tubeliar

    Joined:
    May 21, 2009
    Posts:
    14
    I ran into this thread because i couldn't get the chat example running either. I wanted to run the chat test scene without loader, so using the direct connect method.

    With what i read here i found that you can check and change the used ports with the inspector on the DirectConnectGUI object. The Connect GUI script has different listening and remote ports. This can be correct if the server on another computer is set to use the different port, but nobody is going to do that when figuring out a test scene! It never even crossed my mind that the default values would NEED to be changed!
     
  18. pradeeppandey

    pradeeppandey

    Joined:
    Dec 6, 2010
    Posts:
    3
    I am working with networking example of unity and I gone through all the possible solutions provided above,But still its not working in my case.The problem is same as the first post of this problem..
    waiting for the positive response...

    thanks in advance...
     
  19. pradeeppandey

    pradeeppandey

    Joined:
    Dec 6, 2010
    Posts:
    3
    "Refresh available Servers" is not showing the available servers i made two servers in local lan and having clients to join any of the server but its not displaying the servers available to it....

    thanks in advance...