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

TcpServer / TcpClient OptionKeepAlive have no effect #295

Open
bearyung opened this issue Apr 18, 2024 · 2 comments
Open

TcpServer / TcpClient OptionKeepAlive have no effect #295

bearyung opened this issue Apr 18, 2024 · 2 comments

Comments

@bearyung
Copy link

I have setup the OptionKeepAlive in both TcpServer and TcpClient, the client successfully connect to the server.

However, when I turn off the router to test the keepalive feature, after the time (60 seconds), the client's OnDisconnected() and OnError() have not been triggered, and the server TcpSession's OnDisconnected() and OnError() also have not triggered.

ChatServer.cs

public ChatServer(IPAddress address, int port) : base(address, port)
    {
        // keepalive settings
        OptionKeepAlive = true;
        OptionTcpKeepAliveTime = 60;
        OptionTcpKeepAliveRetryCount = 10;
        OptionTcpKeepAliveInterval = 1;
    }

ChatClient.cs

public ChatClient(string address, int port) : base(address, port)
    {
        // keepalive settings
        OptionKeepAlive = true;
        OptionTcpKeepAliveTime = 60;
        OptionTcpKeepAliveRetryCount = 10;
        OptionTcpKeepAliveInterval = 1;
    }

Would like to know what is the correct way to setup the keepalive so the application can be notified once the connection has been killed in the socket level. Thank you.

Runtime: .NET 8.0
OS: Mac OS 14.4.1 (23E224)
IDE: JetBrains Rider 2024.1

@iBoundary
Copy link

I also encountered this issue. Have you resolved it now? @bearyung @chronoxor

@bearyung
Copy link
Author

I also encountered this issue. Have you resolved it now? @bearyung @chronoxor

No, I have implemented my own heartbeat logic as a workaround.

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

2 participants