Closed mriksman closed 2 years ago
I added ('borrowed' your code from another function) to function void homekit_server_close_clients(homekit_server_t *server)
char address_buffer[INET_ADDRSTRLEN];
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
if (getpeername(context->socket, (struct sockaddr *)&addr, &addr_len) == 0) {
inet_ntop(AF_INET, &addr.sin_addr, address_buffer, sizeof(address_buffer));
} else {
strcpy(address_buffer, "?.?.?.?");
}
CLIENT_INFO(context, "** %s **** homekit_server_close_clients ***** Discon %s", address_buffer, context->disconnect ? "Yes!" : "No");
And you can much easier see the offending list;
>>> HomeKit: No more room for client connections (max 12)
>>> HomeKit: [Client 58] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 59] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 60] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 57] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 56] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 54] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 55] ** 192.168.0.41 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 53] ** 192.168.0.54 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 52] ** 192.168.0.40 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 51] ** 192.168.0.23 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 50] ** 192.168.0.38 **** homekit_server_close_clients ***** Discon No
>>> HomeKit: [Client 49] ** 192.168.0.16 **** homekit_server_close_clients ***** Discon No
Any thoughts? Should HomeKit normally allow multiple connections? Maybe some code to kill older connections to the same IP?
The PR #165 I submitted recently and which has been merged solves this issue...
How can I debug clients not disconnecting properly, and creating another client connection? It's filling up the maximum number of clients.
You can see
192.168.0.40
and192.168.0.41
having multiple connections open.What's the best way to manage this? Kick off duplicate connections?