question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection to non-default host and port

See original GitHub issue

Good day. How can i connect to another host and port?

I tried with this code below, but MLAPI anyway using defaults “localhost” and “7777” port:

using UnityEngine;
using UnityEngine.UI;
using MLAPI;

public class UIController : MonoBehaviour {
    public Text host;
    public Text port;

    public void EventHost() {
        NetworkingManager.singleton.NetworkConfig.ConnectAddress = host.text.Trim();
        NetworkingManager.singleton.NetworkConfig.ConnectPort = int.Parse(port.text.Trim());
        NetworkingManager.singleton.StartHost();
    }

    public void EventClient() {
        NetworkingManager.singleton.NetworkConfig.ConnectAddress = host.text.Trim();
        NetworkingManager.singleton.NetworkConfig.ConnectPort = int.Parse(port.text.Trim());
        NetworkingManager.singleton.StartClient();
    }
}
  • Unity Version: 2018.3.1f2
  • MLAPI Version (Commit # or release version): 5.0.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
TwoTenPvPcommented, Jan 18, 2019

The EventClient code should be correct. The EventHost method is however incorrect. It should be the following:

public void EventHost() {
    UnetTransport.ServerTransports[0].Port = int.Parse(port.text.Trim());
    NetworkingManager.singleton.StartHost();
}

Or for better clarity:

public void EventHost() {
    // Clear the default listen endpoints.
    UnetTransport.ServerTransports.Clear();
    // Adds your own endpoint
    UnetTransport.ServerTransports.Add(new TransportHost()
    {
        Name = "My UDP Socket",
        Port = int.Parse(port.text.Trim()),
        WebSockets = false
    });
    NetworkingManager.singleton.StartHost();
}

Hope this solves your issue.

0reactions
ashkan-saeedi-mazdehcommented, Apr 25, 2021

I realize this is very old but the port and ip are no longer accessible in the config. where should I set them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to connect to non-default sftp port? - Linux Concept
In the “Host” field, enter the hostname or IP address of the SFTP server, followed by a colon and the port number. For...
Read more >
How to connect to default instance using Non-Standard ...
1 Answer 1 · Run the Browser Service · Create a SQL Server Alias on all your client machines, using the SQL Server...
Read more >
Use nondefault ports for the portal's ArcGIS Web Adaptor
This workflow allows an instance of Web Adaptor running on nondefault ports to be configured with the portal, with a reverse proxy server...
Read more >
Connect to a non-default SFTP port
We will show in this article how to connect to an explicit port number, using the sftp utility. The sftp command information: root@web...
Read more >
Running SQL Server 'Default' instance on a non-default (or ...
We can connect to the instance of SQL Server by using its server name, its FQDN, or its IP address followed by a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found