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

Websocket error #429

Closed
AlexKovalevych opened this issue Jul 3, 2015 · 5 comments
Closed

Websocket error #429

AlexKovalevych opened this issue Jul 3, 2015 · 5 comments
Labels

Comments

@AlexKovalevych
Copy link

I've used websocket similar to example in the documentation. After several messages sent getting this error. It happens from time to time unpredictably (means may happen after several requests or work for tens of requests and fail after that). Any idea where can be the problem and how to solve it?

socket.accept() out of system resource
socket: <socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8000)>
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.4.2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/selector_events.py", line 137, in _accept_connection
  File "/usr/local/Cellar/python3/3.4.2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socket.py", line 184, in accept
OSError: [Errno 24] Too many open files
@asvetlov
Copy link
Member

asvetlov commented Jul 3, 2015

You have too many open files (maybe sockets actually).

Looks like you have a Mac, so your system is not under high load.
Thus you don't close some resources (I don't know which ones without looking on code).
I pretty sure aiohttp itself doesn't leak resources if you use it properly.

Perhaps the bug is into your code.

@AlexKovalevych
Copy link
Author

You have too many open files (maybe sockets actually).

Probably yes, but shouldn't server automatically close connections by timeout? For example, i have two users who are online at the same time (two active sockets), but for some reason sockets, created before were not closed properly and currently not used, will they be closed after some period of time?
If not, how to handle this case correctly: user opened a page, socket was created, user closed the page and connection was not closed properly by the client, then user opened a page again and new socket was created, now having two open sockets, etc. Also, how many sockets can be opened by one worker, is there a limit? Thank you for fast response.

@asvetlov
Copy link
Member

asvetlov commented Jul 3, 2015

I cannot add timeout for websockets: they are endless by specification. I mean websocket itself has not timeout for disconnection, you may keep it on for unlimited time until client closes connection.

If you need disconnection by timeout please do it yourself. Don't forget processing ping/pong messages to update timeouts.

user opened a page, socket was created, user closed the page and connection was not closed properly by the client
on tab closing browser should close all opened sockets, so websockets should be disconnected also I think.

how many sockets can be opened by one worker
Do you mean process? It's specified by ulimit -n. On linux box the typical default value is 1024 (may me changed manually if needed).

@AlexKovalevych
Copy link
Author

Thank you, i'll investigate.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants