2 computers on same network connectnig to each other via internet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Asja
    New Member
    • Feb 2009
    • 18

    2 computers on same network connectnig to each other via internet

    I have written an application that runs in a kind of peer-to-peer framework. Servers connect to a masterserver, which a client then queries to receive a list of servers. The client selects a server and connects to that server directly and both the server and client sever their connections with the masterserver.

    Problem: I have the masterserver set up at a location and it is not behind a router or firewall or anything, just directly connected to the internet. I have in a separate location (separate internet connection, too) a server and a client computer on the same network. Both can connect to the masterserver fine. A TCP connection is maintained with clients whilst UDP packets are sent out periodically to both clients and servers. The TCP connection is fine and the UDP packets are always received by the same computer, and always not received by the other one (regardless of which one is the server and which one is the client). When the direct (TCP) connection between the client and server is attempted, however, it doesn't work: "Connection forcefully refused" error message. The standard ports that the application uses are opened for both TCP and UDP on the router. My thoughts are that whilst these ports are set to forward to both computers in the router setup, only one computer receives the UDP packets sent out by the MS and so I'm wondering if the perhaps only one computer is receiving the TCP packets necessary to establish a connection as well.

    Notes: If I run the masterserver on the network behind the router and try to connect to it (as either server or client) from the computer directly connected to the internet the connection is fine (I haven't tested the server-client connection from computers on different networks yet). When the masterserver is run on the same network as the server and client and a local address (192.168.x.x) is used for the masterserver everything works perfectly. In the same situation when a non-local IP is used neither computer can connect to the masterserver as either server or client.

    I would really appreciate any help on this issue since the application is meant to support two computers on the same network connecting to each other via the external masterserver.

    Regards,
    AJ

    P.S. The router is Open Networks in case that helps.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    It sounds like one of the machines is not accessible (the one that never receives any UDP packets).

    Can you share which subnets the three machines are on. Please include the actual IP address subnets, as well as those which are needed to address them publicly across the internet. This is for working out whether the correct addresses are being shared with the other machines (client/ server etc).

    If you are uncomfortable sharing these publicly then please feel free to PM me with the information.

    Comment

    • Asja
      New Member
      • Feb 2009
      • 18

      #3
      Progress but not quite there yet

      Thanks for your suggestion NeoPa.

      OK, an update on the problem:
      It turns out that you can't forward the same port to multiple computers.
      I solved this problem by allowing the user to specify which port
      their machine uses for communication and then forwarding the
      appropriate ports.

      So now all computers in all situations can communicate via TCP
      and UDP correctly with the masterserver. When a client tries to
      connect to a server behind the same router (even if the server is
      running on the same computer as the client), however, I receive
      the "Connection forcefully refused" message. So things have
      progressed but are not quite there yet.

      I have debugged the server application and can confirm that it
      never receives any connection request from the client computer,
      so I presume the problem is once again with the router setup.
      Also, if I run "netstat -a" I can see the server listening for a
      TCP connection on the correct port. When the router is not
      present everything works as intended.

      Also, if the masterserver is moved behind the router, computers
      behind the same router cannot connect to it. Is it possible that
      computers behind the same router cannot establish a connection to
      each other using the external IP?

      Thanks again for any help with this new issue,
      AJ

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Let's determine if it is all happening in the firewall (router), as I suspect.

        Try setting it all up, then turning off the machine that normally reports the connection is forcefully closed (I mean one your client PC is trying to connect to).

        If you get the same message when the machine is powered off, then you can be fairly sure the error message is originating from the firewall.

        Comment

        • Asja
          New Member
          • Feb 2009
          • 18

          #5
          It's the firewall then

          I tried turning the machine off and I get the same message, so I guess the problem is with the firewall. Do you have any idea what could cause this problem or how to fix it?
          Thanks,
          AJ

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            I can only suggest that the port-forwarding is configured correctly.

            This is not something I can help much with as I'm not familiar with the specific firewall, nor exactly what subnets are in use here.

            How many firewalls do you have in total, for your three separate machines?

            Comment

            • Asja
              New Member
              • Feb 2009
              • 18

              #7
              The two machines that are behind the router just have the router (and the Windows firewall), the other machine just has the Windows firewall.

              As far as the port forwarding configuration, I have set up rule for each computer for the relevant port and selected TCP/UDP. Since the computer uses the same number TCP port as UDP port and the UDP works, I don't understand why the TCP doesn't. Maybe I could try setting up separate rules for UDP and TCP.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Originally posted by Asja
                The two machines that are behind the router just have the router (and the Windows firewall), the other machine just has the Windows firewall.
                As I understand it you have three machines. A Master (controlling) Server, a Server and a Client. This answer doesn't make clear which of the machines are behind the firewall/router.

                It may be worth turning off the Windows Firewall for those machines behind the firewall router anyway. At least during the development/testing stage.

                As a general rule, I would advise configuring a single firewall properly, and not deploy multiple levels. This only says you don't have much confidence in either. Furthermore it makes working out exactly what's going on that much harder.
                Originally posted by Asja
                As far as the port forwarding configuration, I have set up rule for each computer for the relevant port and selected TCP/UDP. Since the computer uses the same number TCP port as UDP port and the UDP works, I don't understand why the TCP doesn't. Maybe I could try setting up separate rules for UDP and TCP.
                I would certainly try that, if for no better reason than it will help you to determine where your problem lies. Finding solutions is often as much about finding what isn't the problem, as it is about finding what is.

                Comment

                • Asja
                  New Member
                  • Feb 2009
                  • 18

                  #9
                  The Master Server is behind just the Windows firewall,
                  The Server and Client are behind the router and Windows firewall.

                  I will try disabling the Windows firewall for the server and client as you suggest.

                  I said UDP was working but TCP wasn't. My mistake, none were/are working.

                  Thanks again for all your help so far,
                  AJ

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    No worries Asja. Let me know how you get on.

                    Comment

                    • Asja
                      New Member
                      • Feb 2009
                      • 18

                      #11
                      I tried disabling the Windows firewall for all computers, but it makes no difference.

                      Comment

                      • Asja
                        New Member
                        • Feb 2009
                        • 18

                        #12
                        I just tried connecting to a server behind the router using an external computer and it works, so it only fails when the client is behind the same router as the server.

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32633

                          #13
                          Originally posted by NeoPa
                          Can you share which subnets the three machines are on. Please include the actual IP address subnets, as well as those which are needed to address them publicly across the internet. This is for working out whether the correct addresses are being shared with the other machines (client/ server etc).

                          If you are uncomfortable sharing these publicly then please feel free to PM me with the information.
                          That sounds very much like an answer to my post #2 (quoted) might be helpful. Please be very careful to get these details right, as they have been know to confuse people. If you need any help, just ask.

                          Comment

                          • Asja
                            New Member
                            • Feb 2009
                            • 18

                            #14
                            Info

                            ------
                            Router
                            ------
                            External IP: 118.208.x.x (the last two numbers change periodically)
                            Network IP: 192.168.1.254

                            I got these details by running ipconfig on each of the machines:
                            ------
                            Server
                            ------
                            Network IP: 192.168.1.101
                            Subnet Mask: 255.255.255.0

                            ------
                            Client
                            ------
                            Network IP: 192.168.1.103
                            Subnet Mask: 255.255.255.0

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32633

                              #15
                              Are there not 3 machines involved in this situation? The master server details seem to be missing (quite important info).

                              Comment

                              Working...