Subject: | Error accept Too many open files (24) happened after Cleanup! |
Hello,
it seems that Server-Bayeux doesn't close some tcp connections.
Monitoring the open connections with lsof displays many connections
in the state "CLOSE_WAIT".
After some time the Server hangs with an error message:
Error accept Too many open files (24) happened after Cleanup!
Displaying the CLOSE_WAIT connections at this time shows a record of
more than 900 of them.
I attached a simple test case and the results of it.
Elias
Subject: | client.pl |
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use POE qw(Component::Client::Bayeux);
POE::Component::Client::Bayeux->spawn(
Host => 'localhost',
Port => 8080,
Alias => 'comet',
);
POE::Session->create(
inline_states => {
_start => sub {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('my_client');
$kernel->post('comet', 'init');
$kernel->post('comet', 'subscribe', '/chat/demo', 'events');
$kernel->post('comet', 'publish', '/chat/demo', {
user => "POE",
chat => "POE has joined",
join => JSON::XS::true,
});
$kernel->post('comet', 'disconnect');
},
events => sub {
my ($kernel, $heap, $message) = @_[KERNEL, HEAP, ARG0];
print STDERR "Client got subscribed message:\n" . Dumper($message);
},
},
);
$poe_kernel->run();
Subject: | output.txt |
#################### OUTPUT FROM SERVER ########################################
[2009/11/27 11:54:09] INFO: Bayeux server started. Connect to port 8080
[2009/11/27 11:54:15] DEBUG: New remote request from 127.0.0.1, id 3434A0B6-DB43-11DE-A830-817985FB2ECC:
[
{
"supportedConnectionTypes": [
"long-polling"
],
"version": "1.0",
"channel": "/meta/handshake",
"minimumVersion": "1.0",
"ext": {
"json-comment-filtered": 1
}
}
]
[2009/11/27 11:54:15] DEBUG: Immediate remote response:
[
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"supportedConnectionTypes": [
"long-polling"
],
"version": "1.0",
"channel": "/meta/handshake",
"minimumVersion": "1.0",
"successful": true,
"advice": {
"timeout": 120000,
"reconnect": "retry",
"interval": 0
},
"ext": {
"json-comment-filtered": true
}
}
]
[2009/11/27 11:54:15] DEBUG: New remote request from 127.0.0.1, id 34360F28-DB43-11DE-A830-817985FB2ECC:
[
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"channel": "/meta/connect",
"connectionType": "long-polling"
}
]
[2009/11/27 11:54:15] DEBUG: Immediate remote response:
[
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"channel": "/meta/connect",
"advice": {
"timeout": 120000,
"reconnect": "retry",
"interval": 0
},
"successful": true
}
]
[2009/11/27 11:54:15] DEBUG: New remote request from 127.0.0.1, id 34374514-DB43-11DE-A830-817985FB2ECC:
[
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"channel": "/meta/subscribe",
"id": 1,
"subscription": "/chat/demo"
},
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"channel": "/chat/demo",
"data": {
"user": "POE",
"chat": "POE has joined",
"join": true
},
"id": 2
},
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"channel": "/meta/disconnect",
"id": 3
}
]
[2009/11/27 11:54:15] DEBUG: Immediate remote response:
[
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"id": 1,
"channel": "/meta/subscribe",
"subscription": "/chat/demo",
"successful": true
},
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"id": 2,
"channel": "/chat/demo",
"successful": true
},
{
"clientId": "3434CE2E-DB43-11DE-8B12-817985FB2ECC",
"id": 3,
"channel": "/meta/disconnect",
"successful": true
}
]
[2009/11/27 11:54:15] DEBUG: Queuing message to client 3434CE2E-DB43-11DE-8B12-817985FB2ECC
######################### lsof +i ##############################################
$ lsof +i | grep cometd.pl
cometd.pl 2808 elias 3u IPv4 60069 0t0 TCP *:http-alt (LISTEN)
cometd.pl 2808 elias 6u IPv4 60231 0t0 TCP localhost:http-alt->localhost:57509 (CLOSE_WAIT)
cometd.pl 2808 elias 7u IPv4 60247 0t0 TCP localhost:http-alt->localhost:33320 (CLOSE_WAIT)
cometd.pl 2808 elias 8u IPv4 60249 0t0 TCP localhost:http-alt->localhost:33542 (CLOSE_WAIT)
Subject: | cometd.pl |
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use POE qw(Component::Server::Bayeux);
# Create the server, listening on port 8080
my $server = POE::Component::Server::Bayeux->spawn(
Port => 8080,
Alias => 'bayeux_server',
Debug => 1,
DocumentRoot => 'www',
# Callback => sub {
# print Dumper(@_);
# }
);
$poe_kernel->run();