Placeholder-Software / Dissonance

Unity Voice Chat Asset
72 stars 5 forks source link

Unet LLAPI exception on client reconnect #19

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello,

I'm currently using Unity 5.5.0f3 and Dissonance 1.0.3, and ran into an issue:

  1. Setup a simple LLAPI project as described in documents,
  2. Starting server and client by calling InitializeAsClient() and InitializeAsSever(),
  3. Stopping client by calling StopClient(),
  4. Starting client once more while server is still running produces this log on server and voice chat breaks image
martindevans commented 7 years ago

Hi AndriusGergelis

Could you give me a little more information about the setup?

ghost commented 7 years ago

Ran client and server on different peers and called StopClient() on peer which had ClientEnabled flag set to true. I start client by calling InitializeAsClient(address). Setting log levels to "Trace" did not produce any valuable info. Attached a simple project, with which I was able to reproduce the issue. disonance-test.zip

martindevans commented 7 years ago

Thanks for the project, I can confirm that reproduces the problem. I'm looking into it now :)

ghost commented 7 years ago

Thank you for such a fast response. Would really appreciate a workaround or a fix as soon as possible, the deadline is very near :D

martindevans commented 7 years ago

I actually already identified (at least part of) the problem although I don't have a proposed fix/workaround for it yet.

Line 59 of UNetServer.cs is:

case NetworkEventType.DisconnectEvent:
    ClientDisconnected(senderConnectionId);

This tells the server that the given client has disconnected and the server cleans up it's internal datastructures to remove all reference to that client. This event never happens! This is particularly odd because it's part of UNet which invokes that event...

martindevans commented 7 years ago

Hello again.

We've got a workaround for this problem. Simply add this code into UNetClient.cs:

public override void Disconnect()
{
    base.Disconnect();
    byte error;
    NetworkTransport.Disconnect(_socket, _connection, out error);

    if (error != (int) NetworkError.Ok)
        Log.Error("Failed to cleanly disconnect from Dissonance server at {0}:{1}, Error {2}", _network.ServerAddress, _network.Port, (NetworkError) error);
}

If that resolves the problem, please close this issue.

ghost commented 7 years ago

It did resolved it, thank you very much. Glad we bought this asset.