Comments (13)
Update: I just noticed that the application didn't actually crash, everything still works fine, but I still think this should be handled by the websockets module so it doesn't print "socket.send() raised exception"/stack traces if a client has disconnected (or perhaps pass along the exceptions so they can be handled by applications using the module).
from websockets.
handleConnection
should probably end with:
try:
yield from websocket.recv()
finally:
wsClients[link_id].remove(websocket)
from websockets.
I'm confident that this commit should fix your problem. Let me know if it doesn't work.
from websockets.
Thanks! I've upgraded to version 2.1, and it doesn't print any tracebacks anymore but it still prints:
"socket.send() raised exception.".
from websockets.
Errors should not pass silently -- PEP 20
;-)
from websockets.
I don't disagree with that, but the problem is that the module (asyncio in this case I believe) is logging the error instead of passing along whatever exception that was raised in socket.send(). This way it can't be handled by the consumer of the API/module ("socket.send() raised exception." isn't very descriptive either), so that message is just trashing the logs when in my use case it should just be ignored because it just means that the client has disconnected before/while calling send().
from websockets.
I'll have a second look at this issue.
from websockets.
asyncio logs this message after 5 attemps to write to a closed socket.
If it's just a race condition when your system is dying under load, there isn't much to fix.
But if it's websockets trying to write data to the connection after the socket dies, then I can do something.
from websockets.
It is websockets trying to write to the connection after the remote connection has disconnected (but websockets hasn't context switched enough to fail the yield from recv before the 5 attempts to send). I have only reproduced it under heavy load (running apachebench on the same machine), so feel free to close it if you feel that this isn't a real issue because it only happens under heavy load. It's not very important to me either way, I just thought I'd report it because I didn't expect this behavior.
from websockets.
Would you mind testing pull request #27 and report if it fixes your problem?
I'm sorry, I haven't replicated your setup yet, so there's a bit of trial and error going on.
from websockets.
This pull request is expected to make yield from client.send(json_data)
raise an exception when the socket died, which should allow you to deal with the error as you wish in
https://github.com/marksamman/pylinkshortener/blob/master/app/websocket/__init__.py#L48.
from websockets.
I have confirmed that the pull request fixes my issue. Thanks!
from websockets.
Well thanks a lot for reporting it and persisting until I fixed it ;-)
Let me know if there's anything else I can help with.
from websockets.
Related Issues (20)
- Documentation: Hello-world example using threading instead of asyncio HOT 1
- Duplicate ping/pong ? HOT 2
- Testing against a running websockets server HOT 1
- 0 bytes read on a total of 2 expected bytes HOT 2
- Secure websocket using example code unable to handle unsecured requests HOT 4
- No route to host----when access IPv6 address failed,no attempt was made to access an IPv4 address HOT 1
- How to close a client connection using the threading interface while stuck in ClientConnection.recv
- Can we get more attention in the threaded client interface? HOT 1
- Human-readable representation of a frame is too short HOT 2
- No module websockets.imports HOT 2
- Sync client stops process exit when running in a Thread if not explicitly closed HOT 5
- Python 3.11 incompatible with websockets\legacy\protocol.py Error "got an unexpected keyword argument 'loop'" HOT 1
- Strange problem, client cannot receive messages from the server, after sending a certain amount of messages. HOT 1
- Cannot Send message to a single client.
- handling multiple websocket client connections HOT 4
- Enable to connect ! invalid handshake HOT 5
- recv() is slow HOT 5
- Client state is incorrect HOT 1
- Feature batch receive HOT 2
- [QUESTION] Switching from websocket-client to websockets HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websockets.