No Disconnect Event Is Created When NetworkDriver.Connect() Fails To Establish A Connection

From the documentation of NetworkDriver.Connect()

Establish a new connection to the given endpoint. Note that this only starts establishing the new connection. From there it will either succeeds (a Connect event will pop on the connection) or fail (a Disconnect event will pop on the connection) at a later time.

Apparently, no such Disconnect event will ever be created if the connection attempt fails because the EndPoint can’t be reached.

Edit:
Tested with Unity Transport 2.5.1 and 2.5.3

I mean, it kinda makes sense that no diconnect event occurs when failing to connect, how can you disconnect if you never connected. Wouldnt be the first time Unity Docs are incorrect in some fashion. That said, i know jack S. about NGO.

For eg: in Photon, you would recieve a ‘Failed To Connect’ event.

Looking at the DisconnectReason struct
https://docs.unity3d.com/Packages/com.unity.transport@2.6/api/Unity.Networking.Transport.Error.DisconnectReason.html
I think it is intended that, as the docs state, a Disconnect event should be created.

Not NGO btw. Just Unity Transport.

Ahh i see. Cant really speak on unity built in networking, as i dont use it, but, the general logic seems strange to me just at a glance.

Thanks for the clarify.

How long have you waited for the Disconnect event to show up? I would still expect the event to be raised if the endpoint is not reachable, but it might take a while since we’ll still repeatedly attempt sending connection request messages every second until we’ve reached the maximum number of attempts. Using the default settings, this can take a full minute to happen (which yeah is a bit ridiculous I agree). You can modify these settings as shown here.

Ah! Dumb me just waited for connectTimeoutMS plus a little extra. I’m now just checking until NetworkConnection.GetState() != NetworkConnection.State.Connecting and it produces the Disconnect event.
Thanks!