You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Property to see the status of the server connection #83
We've had some network errors where the server-side socket gets closed in our windows service. We have a background that does a lot of housekeeping. I was looking for a property on TcpHost to give me the status of the underlying connection. (open, closed, error, etc). I do not see such a property exposed. This would allow me to keep trying to re-open the server-side connection if it errors out.
yeah I just don't have time to do it. It should be very simple from looking at the code. Rarely, we get a disconnect on the server-side and we have no way to recover from that because we have no way to know it happened. We have a background housekeeping thread that runs ever 5 seconds where I could check and if it's disconnected spin up a new server listener.
Simple perhaps to give you the status from the host side, but more complex to recover or know this from the client side. One could, if the connection is exposed, even read only, test the state on the host side and re-open the host listener. OR we might be able to have that automatically done using a flag and have the library open a new host/listener if for some reason it has been killed.
This would be a server-side thing only. The client just will error out since the server is no longer listening. We just need a public property on the server-side class that shows the status of the connection/socket.
Implemented for 6.0.1. TcpHost and NpHost now inherit a public Host.Status property. Its HostStatus values are Created, Opening, Open, Faulted, and Closed; listener failures transition the host to Faulted. This reports host-listener lifecycle rather than an individual client connection. Added regression coverage for normal open/close transitions and TCP bind failures on .NET 10 and .NET Framework 4.8.
Activity
tylerje commentedon Nov 3, 2023
You're welcome to submit a PR that does that. My time for maintenance of late has been rather limited.
tylerje commentedon Jan 11, 2024
If time allows, I'll be exploring this as an enhancement.
krjaction50 commentedon Jan 11, 2024
yeah I just don't have time to do it. It should be very simple from looking at the code. Rarely, we get a disconnect on the server-side and we have no way to recover from that because we have no way to know it happened. We have a background housekeeping thread that runs ever 5 seconds where I could check and if it's disconnected spin up a new server listener.
Thanks
tylerje commentedon Jan 11, 2024
Simple perhaps to give you the status from the host side, but more complex to recover or know this from the client side. One could, if the connection is exposed, even read only, test the state on the host side and re-open the host listener. OR we might be able to have that automatically done using a flag and have the library open a new host/listener if for some reason it has been killed.
krjaction50 commentedon Jan 11, 2024
This would be a server-side thing only. The client just will error out since the server is no longer listening. We just need a public property on the server-side class that shows the status of the connection/socket.
tylerje commentedon Aug 18, 2026
Implemented for 6.0.1.
TcpHostandNpHostnow inherit a publicHost.Statusproperty. ItsHostStatusvalues areCreated,Opening,Open,Faulted, andClosed; listener failures transition the host toFaulted. This reports host-listener lifecycle rather than an individual client connection. Added regression coverage for normal open/close transitions and TCP bind failures on .NET 10 and .NET Framework 4.8.