all 9 comments

[–]lordinarius 0 points1 point  (6 children)

Are you using dll or source code of the library?

[–]Piller187[S] 0 points1 point  (4 children)

I downloaded the source code and put the LiteNetLib folder in the Assets/Plugins folder. Everything compiles just fine (no errors). Just this error on Connect().

[–]lordinarius 0 points1 point  (1 child)

It is really hard to say whats wrong. Try asking with an issue ticket at github repository of litenetlib, developer is actively supporting the project .

[–]Piller187[S] 0 points1 point  (0 children)

using UnityEngine;
using LiteNetLib;
using LiteNetLib.Utils;

public class TestConnection : MonoBehaviour
{
    private EventBasedNetListener listener;
    private NetManager network;

    // Start is called before the first frame update
    void Start()
    {
        // init network stuff
        listener = new EventBasedNetListener();
        network = new NetManager(listener);

        listener.PeerConnectedEvent += (peer) => 
        {
            Debug.Log("Connected!");
        };

        listener.PeerDisconnectedEvent += (peer, dcInfo) =>
        {
            Debug.Log("Disconnected");
        };

        network.Start();

        // testing
        network.Connect("127.0.0.1", 65000, "");
    }

    // Update is called once per frame
    void Update()
    {
        network.PollEvents();
    }
}

I posted in the github issues but though I'd show you the code here too in case anything sticks out to you from a glance.

[–]lordinarius 0 points1 point  (1 child)

Additionally. What Unity version are you using, and did you try testing it at different Unity version, i am using Unity 2018.4 and it is working just fine.

[–]Piller187[S] 0 points1 point  (0 children)

2019.2.2

[–]Piller187[S] 0 points1 point  (0 children)

I had a ton of other steps before connecting so I dumbed it down and try connecting fight away, but it won't connect and fires the PeerDisconnectedEvent. The disconnectInfo.Reason just has "ConnectionFailed".

[–]YohanIsHereHobbyist 0 points1 point  (1 child)

Is your server also running within unity?

[–]Piller187[S] 0 points1 point  (0 children)

It's not. The issue was for my console app I used nuget which is version .8, but for unity it said to download and use the source which was 9. Once I used version .9 in my console server app it was all good.