Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
0
Question by Kingofweirdos · Jan 09, 2018 at 07:12 AM · c#multiplayerbasicnot foundquery

Query not found-masterserver.requesthostlist

Hi guys I am using masterserver.requesthostlist and I keep getting the error that the gametype or for me the serverName isn't found. I am using:

Public game object derp; MasterServer.RequestHostList(derp.GetComponent().serverName);

serverName is a string the player enters before the server is even registered, when people hit the join button then the above code begins running so I was wondering if there was a fix to this issue. Thank You, Kingofweirdos

Comment
Add comment · Show 2
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 Kingofweirdos · Jan 09, 2018 at 09:06 AM 0
Share

If you do not understand just write a comment and also @LukasLicek can u look at this, Thank You

avatar image LukasLicek Kingofweirdos · Jan 09, 2018 at 02:32 PM 0
Share

@$$anonymous$$ingofweirdos, could you please add the script with serverName ? I may will edit my answer afterwards :)

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Ginxx009 · Jan 09, 2018 at 09:14 AM

In this forum maybe it will help you?

Comment
Add comment · 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
0

Answer by LukasLicek · Jan 09, 2018 at 02:35 PM

Hello @Kingofweirdos , I did look into your code and maybe I have found the source of your problem.

I got the same error when I was trying to connect trying to connect via server name, but I should have use GameType. I think that you are trying to connect via server name, but you should use GameType. I've written a simple code, which should demonstrate that:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class TestScript : MonoBehaviour {
 
     public string UniqueGameType;
     public string serverName;
     public string comment;
 
     void OnMasterServerEvent(MasterServerEvent masterserverevent){
         if (masterserverevent == MasterServerEvent.RegistrationSucceeded) {
             Debug.Log ("RegistrationSucces");
                         //WEIRD LINE
             MasterServer.RequestHostList (UniqueGameType);
         }
     }
 
 
     void OnGUI() {
         if (GUILayout.Button ("Start Server"))
         {
             MasterServer.ClearHostList();
             // Use NAT punchthrough if no public IP present
             Network.InitializeServer(32, 25002, !Network.HavePublicAddress());
             MasterServer.RegisterHost(UniqueGameType, serverName, comment);
         }
 
         if (GUILayout.Button ("Connect"))
         {
             Debug.Log ("Requesting server: " + UniqueGameType);
 
             MasterServer.RequestHostList (UniqueGameType);
 
             HostData[] hostData = MasterServer.PollHostList();
             Debug.Log ("Number of servers: "+hostData.Length);
             //write server info to console
             if (hostData.Length > 0) {
                 Debug.Log ("Requesting name: " + hostData [0].gameName);
                 Debug.Log ("Requesting type: " + hostData [0].gameType);
                 Debug.Log ("Requesting ip: " + hostData [0].ip);
             }
         }
     }
 }

Another issue is your idea with loading scenes. I think, that maybe when you load them, Unity will not execute registering host, because it takes a while and you load next scene, before it can finish.

Please take in account, that I dont work with HLAPI and Networking very often. So, for Ex. I have to RequestHostList two times in my code. (Extra request commented as WEIRD LINE :D). That being said, I hope I've helped you and good luck :)

Comment
Add comment · Show 4 · 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 Kingofweirdos · Jan 09, 2018 at 10:17 PM 0
Share

@LukasLicek I am using the following code in order to make the master server I don't think it is a a problem with the derp.getcomponent().serverName; I am currently testing I will update you through a further comment.

avatar image Kingofweirdos · Jan 09, 2018 at 10:17 PM 0
Share
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 using UnityEngine;
 using UnityEngine.Scene$$anonymous$$anagement;
 public class TestScript : $$anonymous$$onoBehaviour {
     public HostData[] hostData;
     public bool create;
     public bool joining;
     public string serverPassword;
     public string playerName;
     public string clientPassword;
     public Vector2 scrollPosition;
     public Button createbutton;
     public Button joinbutton;
     public InputField playerNameInput;
     public InputField serverNameInput;
     public string serverName;
     public InputField serverInfoInput;
     public string serverInfo;
     public Button makebutton;
     public Button backbutton;
     public InputField serverPasswordInput;
     public static string serverNameStatic;
     void ServerInfo1(){
         if (serverInfoInput.text == "") {
             serverInfoInput.placeholder.GetComponent<Text>().text = "Please Enter Server Info";
         } 
         else{
             serverInfo = serverInfoInput.text;
         }
     }
     void ServerName1(){
         if (serverNameInput.text == "") {
             serverNameInput.placeholder.GetComponent<Text>().text = "Please Enter A Server Name";
         } 
         else{
         serverName = serverNameInput.text;
         }
         }
     void $$anonymous$$akeServer(){
         if (serverName == "") {
             serverNameInput.placeholder.GetComponent<Text> ().text = "Please Enter A Server Name";
         }
         if (serverInfo == "") {
             serverInfoInput.placeholder.GetComponent<Text>().text = "Please Enter Server Info";
         }
         else {
             serverStart ();
         }
         }
     void ServerPassword() {
         if (serverPasswordInput.text == "") {
             serverPasswordInput.placeholder.GetComponent<Text>().text = "Please Enter Password Info";
         }
         else {
             serverPassword = serverPasswordInput.text;
         }
     }
     void Back(){
         Scene$$anonymous$$anager.LoadScene ("Second");
         create = false;
         joining = false;
     }
     void Create () {
             create = true;
             Scene$$anonymous$$anager.LoadScene ("Creating");
         }
     void OnEnable(){
         Scene$$anonymous$$anager.sceneLoaded += OnSceneLoaded;
     }
     void OnSceneLoaded(Scene scene, LoadScene$$anonymous$$ode mode){
         if(scene.name.Contains("Joining")){ 
             $$anonymous$$asterServer.RequestHostList (serverName);
         }
     }
     void Join () {
             joining = true;
             Scene$$anonymous$$anager.LoadScene ("Joining");
         }
     void PlayerName()
     {
         playerName = playerNameInput.text;
     }
     void serverStart(){
         if (serverPassword != "") {
             Network.inco$$anonymous$$gPassword = serverPassword;
         }
         Network.InitializeServer(15,25001, !Network.HavePublicAddress());
         $$anonymous$$asterServer.RegisterHost(serverName, playerName, serverInfo);
     }
     void On$$anonymous$$asterServerEvent($$anonymous$$asterServerEvent masterserverevent){
         if (masterserverevent == $$anonymous$$asterServerEvent.RegistrationSucceeded) {
             Scene$$anonymous$$anager.LoadScene ("Lobby1");
         }
     }
 }
avatar image Kingofweirdos · Jan 09, 2018 at 10:19 PM 0
Share

alt text

error-file.png (11.7 kB)
avatar image Kingofweirdos · Jan 09, 2018 at 10:27 PM 0
Share

@LukasLicek I forgot to type the portion in the original portion of the question I can understand where the confusion came from

avatar image
0

Answer by Bunny83 · Jan 10, 2018 at 11:41 AM

Since this question somehow get constantly bumped i want to clear up some things here.


First of all the MasterServer is part of the legacy networking system (RakNet). It's still in the engine but has nothing to do with the new UNet system. The legacy system shouldn't be used for new projects.


Furthermore as far as i know Unity has shut down the default development MasterServer they used to host on their own server. So you have to host and use your own MasterServer build. That also means you have to know the IP and port of your masterserver and have to set them. This was always necessary even back then when RakNet was the active networking engine. The development Masterserver which was hosted by Unity was only meant for development testing.


People also seem to confuse what the "GameType" parameter is good for. The point here is that a single MasterServer could handle servers for many different games at once. The GameType is a filtering string. This string should be constant and unique to your game. RequestHostList can only return servers which has been registrated with the exact same gametype string. Think about it like Valves source engine. The "gametype" would be something like "TeamFortress2", "HalflifeDM", "Left4Dead", ... So the server browser only shows servers which actually run the desired game.


Next you have to keep in mind that "RequestHostList" is an asynchronous request. It can take several seconds until you actually received the host list and it doesn't have to arrive at once. That's why you have to continously call PollHostList() to actually get new results which you should display in a list.


Finally keep in mind that the server who registered itself to the master server is a seperate entity from players which request the host list who wants to join a server. Information typed in by the server creator is not available to other clients. If you use a user typed in "gametype" to register the server, the clients which want to join the server would need to type in the exact same string or the master server won't return anything. Allowing user gametypes would however cause some problems. When two server creators use the same string (e.g. "MyServer"), all clients which want to join "MyServer" would see those two servers.


Debugging network related issues is really hard from the outside. It's already quite complicated when you directly work with it as there are many different things which can go wrong. From the information given we can't deduce what might be the issue here.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Multiplayer Respawning Problems 0 Answers

How to make a simple co-op (2-player) Game? 1 Answer

Code Wont Work? 0 Answers


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