Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client will disconnect immediately after connect to the server? #30

Open
v23v opened this issue Aug 20, 2021 · 3 comments
Open

client will disconnect immediately after connect to the server? #30

v23v opened this issue Aug 20, 2021 · 3 comments

Comments

@v23v
Copy link

v23v commented Aug 20, 2021

The server is running and Broadcasting unreliable message to all connected clients in update function. At this time, any other new client can not connect to this server.
The log shows as below:
============log info=============
KcpClient: connect to 172.xxx.xxx.xxx:7777
KcpConnection: sending Handshake to other end!
KCP: received unreliable message in state Connected. Disconnecting the connection.
KCP Connection: Disconnected.
KCP: OnClientDisconnected

it seems that the code in KcpConnection.cs call the Disconnect() function. [the last line below]

` if (state == KcpState.Authenticated)
{
// only process messages while not paused for Mirror
// scene switching etc.
// -> if an unreliable message comes in while
// paused, simply drop it. it's unreliable!
if (!paused)
{
ArraySegment message = new ArraySegment(buffer, 1, msgLength - 1);
OnData?.Invoke(message);
}

                        // set last receive time to avoid timeout.
                        // -> we do this in ANY case even if not enabled.
                        //    a message is a message.
                        // -> we set last receive time for both reliable and
                        //    unreliable messages. both count.
                        //    otherwise a connection might time out even
                        //    though unreliable were received, but no
                        //    reliable was received.
                        lastReceiveTime = (uint)refTime.ElapsedMilliseconds;
                    }
                    else
                    {
                        // should never
                        Log.Warning($"KCP: received unreliable message in state {state}. Disconnecting the connection.");
                        Disconnect();
                    }`
@BentiGorlich
Copy link

I have the excact same issue at the moment

@MrGadget1024
Copy link
Contributor

Related to this perhaps?
MirrorNetworking/Mirror#2900

@Clept0
Copy link

Clept0 commented Nov 22, 2021

You can fix this by turning off "NonAlloc" in the KCP settings in the transport component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants