Support => TNet 3 Support => Topic started by: rxmarcus on July 24, 2017, 05:07:51 PM
Title: Can't connect troubleshooting advice
Post by: rxmarcus on July 24, 2017, 05:07:51 PM
So I just launched my game today. For some users they haven't had to open any ports to connect. Others I've had them open port 5128 and then other clients can connect to them.
And I have other users who open the port and I'm still not able to connect to them. One of them has an Ivp6 address (Which supposedly avoids port issues?) and I still cannot connect to him.
Just looking for more advice at what I can have my users do to get their games to connect. Any help is appreciated!
Title: Re: Can't connect troubleshooting advice
Post by: ArenMook on July 24, 2017, 07:44:46 PM
You don't need to open ports if UPnP is supported on the router. Most do, but not all, and some do in an odd way like Apple's Airport so they don't work with TNet's approach. If the user is behind more than one firewall (two routers, router + model that hasn't been set to bypass etc) then it likely won't be possible to connect to them. If you want it to always be possible to connect, have a central server you'll run yourself. You can either use it as your game server where each game instance is going to be a separate channel ID (like I did with Starlink), or just have it be your "official" game server like I did with Windward. Players can still host their own private servers with either scenario, and with Windward they will even show up on the server list (as you can register with a remote lobby) -- but they have to run the stand-alone server explicitly for this purpose. Servers launched from within the game don't show up, intentionally slow -- but of course it's still possible to use Steam's join friend's game functionality to share the server's info (ip, port) and allow direct joins. Provided their game is accessible of course -- and as I mentioned, not all players will have their machines be accessible due to the reasons mentioned.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 11:03:02 AM
Thanks for the detailed response.
Can you give more details about running my own central server? Is that the same thing as me hosting a dedicated server on something like Amazon web services?
Is your central server an actual instance of your game on the unity engine? Or what does your "stand alone server" look like?
This sounds like the direction I'll want to head if I can understand it a bit more! :)
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 03:55:03 PM
Yes, that's exactly it. It could be a cheap VPS, too, though, like through linode or digitalocean. TNet's server doesn't require a lot of resources, so the cheapest plan should work.
No, it's just the standalone TNet server. Nothing tied to Unity.
The standalone server should be in a zip file within the TNet asset. The zip file is called "TNetServer.zip". It's precompiled so you should be able to just run it.
I think the setup ArenMook is describing is as follows: You have a single standalone server running. Your players connect to that. Then you split this single server into multiple channels. Each channel is its own separate instance (or "match" in your case) of the game. In this way, each channel kind of becomes its own sub-server. So, in your case, I imagine joining a match currently consists of three steps: TNServerInstance.Start for the host, then TNManager.Connect followed by TNManager.JoinChannel for everyone. With this setup it'd just be TNManager.Connect on startup (only once!) and TNManager.JoinChannel for each match.
Some batch/bash files to startup the server (I don't know what I'm doing here, but it works for me): Windows (save as RunServer.bat):
@echo off
start "TNet Test Server""TNServer.exe"-name "TNet_TestSrv"-tcp 5127-udp 5128-tcpLobby "127.0.0.1""5129"
For linux you'll need to install mono. I think it's just sudo apt-get install mono-complete. Dunno the yum equivalent, I think you can find instructions on mono's website for a bunch of different package managers.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 05:07:42 PM
If the "Host" is still calling TNServerInstance.Start(), then what is the purpose of the TNetServer? I currently have TNetServer running on AWS for my Lobby Server.
I changed my startup script to use your suggestion so now it is hosting a lobby server and a game server.
With the setup you guys are describing, won't I need all players including the host to connect to the IP address of my AWS TNet "Game Server"?
Sorry in advance for not understanding!
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 05:12:57 PM
Sorry, I wasn't clear. I was comparing your current setup with the described setup. In the described setup, you only call TNManager.Connect at startup then TNManager.JoinChannel for each match. No one calls TNServerInstance.Start.
Yes, all players should connect to your standalone game server (and lobby server if you want, but only necessary if you'd like to see player-hosted servers in a server browser or something).
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 05:45:08 PM
With this setup.... how does TNManager.isHosting behave?
Every player that connects is just a client and not a host right? I've written lots of my game logic that depends on TNManager.isHosting
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 05:46:28 PM
Exactly the same as before: the first player that joins a channel is that channel's host.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 05:54:30 PM
Oh sweet, I didn't realize that is how it worked. I had assumed whoever called TNServerInstance.Start() was the host.
Really appreciate your quick responses! =)
Trying to switch over to this method rapidly so my players can have a better experience.
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 06:03:41 PM
No problem. Yeah, "host" is a bit misleading: it should be named "operator" to clear up confusion. The host isn't actually hosting anything; it's just a flag that indicates authority.
Good luck with your game ^.^
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 07:56:48 PM
So I've got this basically setup now using Amazon web services, but my games are now REALLY laggy. Is amazon web services maybe not meant for hosting game servers? I'm getting about 50ms ping to the server which isn't bad, but its responding WAY slower / lagging than it was when I was doing P2P server hosting.
Any ideas?
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 08:10:35 PM
No idea. I've never used Amazon's services. This thread touches on EC2 instances though: http://www.tasharen.com/forum/index.php?topic=4756.0 Apparently poor latency is expected?
I'd just go with linode or digitalocean. They're just as scalable and ridiculously cheap. I've never had problems with either provider.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 11:10:03 PM
Thanks, I got a droplet setup on Digital Ocean.
One issue I'm having when trying to start TNetServer.exe like so
Is that I get an error: "TcpLobbyLink is connecting to 127.0.0.1:5129... TcpLobbyLink Error: Connection refused"
If I remove the "127.0.0.1" from the command, it starts up fine and I'm able to connect to it. BUT, I'm trying to figure out also how I can have the game server named in the lobby server. Right now it has no title.....
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 11:17:01 PM
Nevermind, it IS showing the server name now. Do I need to worry about the "127.0.0.1" issue I mentioned?
Also, how can I edit a forum post?!
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 11:28:36 PM
That specifies a remote tcp lobby to reigster with. If you have your lobby server on another machine you'll need to specify its address and port there. Omitting an address and just using the port starts the lobby server on the same machine.
Can't edit posts - some people were editing out information that could be helpful to others in the future.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 25, 2017, 11:36:36 PM
Ok that makes sense.
So with having 1 "dedicated" server, that has multiple channels for allowing multiple "matches".... I am pretty limited in the details that I can share with a user right?
Is there any way to tell the player how many players are connected to my dedicated server or how many channels (matches) there are or anything like that? Or only server name?
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 25, 2017, 11:46:26 PM
Not at all. Use TNManager.GetChannelList(...) to get a list of every channel on a server. For each channel, this gives you: ID, current number of players, max number of players, whether the channel requires a password, if the channel is persistent, the name of the scene the channel is currently set to, and the entire DataNode (anything you set via SetChannelData).
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 26, 2017, 09:54:35 PM
Perfect, that is a great help.
So, right now I have my user connect to my "region" server that I'm hosting on digital ocean right when the game starts up. This way I can call TNManager.GetchannelList() to display all of the open "matches" on the server.
BUT, if I want a player to then start his own private server, I need to call TNManager.Disconnect() to disconnect from my region server and then run TNServerInstance.Start() ?
That's what I'm attempting at the moment and am still working through some issues, but is there a better way to handle the situation?
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 26, 2017, 10:23:58 PM
You'll be facing the same issues, though....? The whole point of having a dedicated publicly-accessible server is to eliminate player-to-player connections. Players aren't usually on publicly-accessible networks, hence your connectivity issues.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 26, 2017, 10:38:35 PM
yea, I was hoping to still allow players to host their own games if they wanted to with their buddies for example, rather than joining the quick play "region" server
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 26, 2017, 10:45:16 PM
Oh, then yeah you'd do exactly that. You can specify a lobby server to register with in the TNServerInstance.Start(...) call, too, if you want it to be visible to other clients in a server browser or something. Or (and), like ArenMook said, you can use Steam's Join Game functionality.
Title: Re: Can't connect troubleshooting advice
Post by: rxmarcus on July 26, 2017, 11:07:36 PM
Sorry, one more question. So with using a Server hosted somewhere like Digital Ocean, really that adds a decent amount of latency as now all game packets are routed through it rather than directly from player to player correct?
Title: Re: Can't connect troubleshooting advice
Post by: cmifwdll on July 26, 2017, 11:58:07 PM
No, all packets are routed through the game server regardless. In most (all?) cases, having a dedicated server will reduce latency as they're hosted in datacenters. If the server is hosted in LA and a user is in Egypt then of course they'll have poor latency, but it'd be even worse with player-run servers as you're adding another hop (at minimum). Digital Ocean has datacenters worldwide, though, so you could just set up a server in each major region if it's a huge problem for your game. There are analytics libraries you can add to your game that'd help you map out where your playerbase is clustered, so you can get a better idea of which regions to invest in.