Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

too many file descriptors in select() with NGINX on Windows #376

Closed
mhdaouas opened this issue Aug 5, 2021 · 5 comments
Closed

too many file descriptors in select() with NGINX on Windows #376

mhdaouas opened this issue Aug 5, 2021 · 5 comments

Comments

@mhdaouas
Copy link

mhdaouas commented Aug 5, 2021

I have a Vue 2 SPA app which opens several websocket connections upon mounting specific components and closes them when the user leaves those components (during their destruction) or in other words when accessing/leaving specific pages.

The app is served with a NGINX server on a Windows Server 2016 VM.

An instance of Daphne runs with the following command:
daphne -b <VM IP adress> -p <port> <django app>

It looks like I need to optimize my code and avoid opening and closing the same websockets each time I access/leave specific pages of the app.

I noticed that each time a connection is opened, a new incremented port is opened (I start with 8443 and reach ports like 15078).

After some time Daphne crashes with the following Python error message:
too many file descriptors in select()

Is there a way to force opening the same port for each websocket at least (each "URL") instead of using a new one for the same websocket or any way to limit file descriptor usage?

I saw also that there is a possibility to run several Daphne instances. Can this method resolve my issue ? If yes, how to implement it with NGINX?

Thank you for your kind support.

@carltongibson
Copy link
Member

Hi. There's not really enough to go in here but first step would be to check and raise the open file descriptor limit.

Then it would be look into whether sockets are being closed. How many connections are open are once? If you have regular disconnects shouldn't that balance? Etc. 🤔

This isn't really something Incan help you with directly unless you can pin down an addressable issue...

@mhdaouas
Copy link
Author

mhdaouas commented Aug 6, 2021

I have 39 websockets that I keep opening and closing in an erratic way. Maybe I need to open them once after user logs in and keep them in that state because it looks like file descriptors are not freed when I close a websocket.

Also it looks like it is impossible to raise the fd limit in Windows/Python (I couldn't find any way).

@carltongibson
Copy link
Member

Also it looks like it is impossible to raise the fd limit in Windows/Python (I couldn't find any way).

I didn't experiment yet but, a quick Google search suggested this: https://stackoverflow.com/a/28212496

@carltongibson
Copy link
Member

Some idea of the existing limit, and the progression over time would be interesting to see. If it's just set at 255, it's not much of a surprise to see it being exceeded...

@carltongibson
Copy link
Member

This isn't really a Daphne issue. I'm going to close it.

@carltongibson carltongibson closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants