Closed kavin027 closed 7 years ago
@kavin027 the end of connection takes some time to be detected when it is not properly closed like the test you did. The server do not detect its termination immediately. A good practice is to set the ping message interval to a short value (according with you application needs, how fast you want to detect the client has disconnected) and a not so big socket output buffer. This way the server will periodically tries to write messages to each subscriber and at some point it will receives an error indicating that the client is no longer there and closes the connection at the server side, counting down the number of subscribers.
First, I start a subscriber by curl -s -v 'http://localhost/sub/my_channel_1' on a mobile phone. I got stat messages ( curl -s -v 'http://localhost/channels-stats?id=my_channel_1') {"channel": "my_channel_1", "published_messages": 0, "stored_messages": 0, "subscribers": 1}
Then I tune my mobile phone into a flight mode (disconnect the network) I expected that subscribers should be 0. However, I still got stat messages ( curl -s -v 'http://localhost/channels-stats?id=my_channel_1') {"channel": "my_channel_1", "published_messages": 0, "stored_messages": 0, "subscribers": 1}
Please help me! Thank you!