Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

events.js:45 Error: EBADF, Bad file descriptor #1189

Closed
edsu opened this issue Jun 16, 2011 · 8 comments
Closed

events.js:45 Error: EBADF, Bad file descriptor #1189

edsu opened this issue Jun 16, 2011 · 8 comments

Comments

@edsu
Copy link

edsu commented Jun 16, 2011

Just wondering if anyone has seen this error pop up intermittently when node is under load:

events.js:45
        throw arguments[1]; // Unhandled 'error' event
                   ^
Error: EBADF, Bad file descriptor

I haven't been able to reproduce it with a test. But have tried both trunk and v0.4 (stable). My app does use socket.io. Is this perhaps some limitation of my system? Can anyone recommend some ways I could help figure out what is going on here?

@edsu
Copy link
Author

edsu commented Jun 16, 2011

@acdha helped me tune my TCP stack to more aggressively reap connections, since I was getting close to a thousand on my small linode VPS ... so my problem was lower level than node. If you are curious I lowered both of these from 60 to 30:

sysctl net.ipv4.tcp_fin_timeout=30
sysctl net.ipv4.tcp_tw_recycle=30

@tommedema
Copy link

What does this do? It would be really helpful if someone could create a guide with all these settings, including http agent settings etc. so that the rest of us do not need to experience such downtime ourselves when services get popular.

@edsu
Copy link
Author

edsu commented Jun 16, 2011

Basically I did a netstat --tcp and noticed a lot of connections in TIME_WAIT. The number of connections grew and grew to about 1000 connections, and then I think I hit some practical system limit (eventhough ulimit said there was no limit, there is a practical limit). If anyone knows how to determine the limit it would be interesting to know how to do that.

The sysctl commands basically lower the time that a connection will be kept alive, which causes connections in TIME_WAIT to be reaped sooner. I'm not sure that it completely fixed my problems, but at least node isn't getting a fatal exception for now.

@edsu
Copy link
Author

edsu commented Jun 17, 2011

I think this is some system tuning issue and not anything to do w/ node, so I'm closing this ticket.

@kc-dot-io
Copy link

I'm seeing this consistently with express 3 in both my dev and prod envs if I enable connect-session-mongo or express.static.

OSX 10.7.4, node 0.6.5, 0.8.11, 0.8.14 & Ubuntu 10.4LTS , node 0.6.5

Issue is referenced above. I tried the suggestion above on my unix server but no luck.

@nazreen
Copy link

nazreen commented Oct 25, 2017

@slajax what was your solution?

@kc-dot-io
Copy link

I have no idea. I can't remember it was a long time ago. I may have had to increase the ulimit?

@nazreen
Copy link

nazreen commented Oct 26, 2017

ok thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants