MirrorNetworking / MirrorNetworking/Telepathy

Server disconnects client after ~3 seconds.

Open
#101 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.2k
Forks
141
PR merge metrics
No merged PRs in 30d

Description

The title says it all. Here is the server and client code.

Server code:

using System;
using System.Text;
using Telepathy;

namespace TelepathyTestServer {
    class Program {
        static void Main(string[] args) {
            const int MaxMessageSize = 8 * 1024;

            Encoding utf8 = Encoding.UTF8;

            Server server = new Server(MaxMessageSize);

            server.OnConnected = (connectionId) => {
                Console.WriteLine("Client [{0}] connected.", connectionId);
                byte[] msg = utf8.GetBytes("Hello from server.");
                server.Send(connectionId, new ArraySegment<byte>(msg));
            };

            server.OnData = (connectionId, data) => {
                Console.WriteLine(connectionId + " Data: " + utf8.GetString(data.Array, 0, data.Count));
            };

            server.OnDisconnected = (connectionId) => Console.WriteLine("Client [{0}] disconnected.", connectionId);

            server.Start(5200);

            while (true) {

                server.Tick(100);

                System.Threading.Thread.Sleep(1);
            }
        }
    }
}

Client code:

using System;
using System.Text;
using Telepathy;

namespace ClientTest {
    class Program {
        static void Main(string[] args) {
            const int MaxMessageSize = 8 * 1024;

            Encoding utf8 = Encoding.UTF8;

            Client client = new Client(MaxMessageSize);

            client.OnConnected = () => {
                Console.WriteLine("Connected to server.");
                byte[] msg = utf8.GetBytes("Hello from client.");
                client.Send(new ArraySegment<byte>(msg));
            };

            client.OnData = (data) => Console.WriteLine(utf8.GetString(data.Array, 0, data.Count));

            client.OnDisconnected = () => Console.WriteLine("Disconnected from server.");

            client.Connect("127.0.0.1", 5200);
            System.Threading.Thread.Sleep(100);

            while (true) {

                client.Tick(100);

                System.Threading.Thread.Sleep(1);
            }
        }
    }
}```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the disconnect with the supplied C# server and client programs, starting at server.Tick(100), client.Tick(100), and the OnDisconnected callbacks. Trace the connection lifecycle around those entry points and use the console output to identify why the client disconnects after about three seconds; done means the sample client remains connected during normal operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.