Comments (8)
Please update the examples.
Don't worry about the README, we stopped using mddoc and use nimdocs now. I can change that part after your PR.
from ws.
I don't even know if WebsocketClosedError
should be an error xP That one seems pretty integral for a websocket server that needs to keep track of connections.
Should it perhaps just be called WebsocketClosed
? WebsocketClosedExcpetion
?
Doesn't really matter but hey, semantics in programming sure is fun...
from ws.
Basically any exception from the websocket is a close. Would you handle WebSocketProtocolMismatchError, WebSocketHandshakeError differently?
I think close should be an exception as the expected path for web socket to remain open forever.
from ws.
While I see what you mean, I also think that a specific error as possible should be raised. I checked the test cases and a bunch of them except WebSocketError and assume that the thing that went wrong is in fact what the test is for, but with that mentality we might as well just raise Exception since "it wouldn't be handled differently anyway" xP The test for protocol doesn't even except WebSocketError just 'except:' and then compares the error message. This seems unacceptable? a WebSocketProtocolMismatchError
would be a better solution here.
If the new exceptions are all of 'object of WebSocketError', old try-excepts would still work like they already do and the tests could become more specific. It wouldn't cost anything but would allow for cleaner code.
Some code duplication could go away as well since the WebSocketClosedError is raised in quite a few places. Perhaps a simple 'newWebSocketClosedError' with the correct message should be made?
from ws.
I also beleive that this test (test_protocol_arr) is supposed to find a WebSocketProtocolMismatchError
, but the actual WebSocketError
being raised here is Failed to Upgrade (Possibly Connected to non-WebSocket url
since the cb() responds with 404. Is this correct?
from ws.
I would not mind WebSocketError hierarchy with WebsocketClosed, WebSocketProtocolMismatchError etc... I don't need it though, so I will not make this myself, but PRs welcome.
My fear is that we add this complexity but its not used by anyone in real production system and just creates a bigger bug surface.
from ws.
Well, I believe that having more specific errors does the opposite of creating a bigger bug surface since it allows for better tests and debugging.
Users can still just except WebSocketError if they don't care and catch them all.
I'll make a PR since I do want this for myself anyway :)
Should the README be updated as well to contain the new Errors? Should the chatserv er example still use except: WebSocketError
for the closing sockets or should it specifically except WebSocketClosedError
?
from ws.
I updated the read me to our new style. Feel free to mess with it.
from ws.
Related Issues (20)
- Can't connect to socket.io even after transformation HOT 6
- Question: can this library be used when compiling to JS target HOT 1
- Can't ping eninge io websocket HOT 3
- Key not found: sec-websocket-protocol HOT 2
- "yield only allowed in iterator" error when trying example HOT 1
- Custom error types throwing "undeclared identifier" error when running examples from fresh nimble install on v0.4.3 HOT 3
- ws breaks Nim CI HOT 7
- Typo in README (complaint -> compliant)? HOT 1
- ws with JS backend? HOT 2
- Test example fails HOT 2
- server can't keep websocket connection alive and won't send any data HOT 14
- pingLoop causes SEGVs HOT 2
- Ws server protected by cloudflare vulnerable to simple attack HOT 2
- Poor performance while sending data through opened sockets HOT 1
- Sending custom headers when opening a client connection HOT 2
- Investigate recv not reading everything as the Nim Docs say it should.
- dont work HOT 1
- gcsafe error HOT 2
- Alternate Opcodes? 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 ws.