Comments (5)
You are right, the reason this was done was because I did not wan't to block the hub if the Session.output channel was full.
I have to think about how to ensure that messages are read/written in order as I also notice that
there might be problems with this piece of code:
if t == websocket.TextMessage {
go messageHandler(s, message)
}
Thank you for bringing it up
from melody.
As I am developing https://github.com/centrifugal/centrifugo similar in many aspects I also have the same task:
sending to client: https://github.com/centrifugal/centrifugo/blob/master/libcentrifugo/hubs.go#L300
client's send
method implementation: https://github.com/centrifugal/centrifugo/blob/master/libcentrifugo/client.go#L177
So Centrifugo uses separate unlimited size queue for every client. At first stages I used buffered channel with size 256 by default and closed client's connection when that buffer was full and sending into channel blocked. But it behaved bad in case of high message rate as client was disconnected just because it received more than 256 messages at one moment. Now with queue there is a little overhead but predictable behaviour.
I have another problem with dealing with slow clients (lots of allocations in code as I don't have access to SetWriteDeadline
method at moment - I use SockJS not just Websockets - but hopefully will be able to improve this in near future). But this is not a problem for Melody as you already use SetWriteDeadline
.
So this is one of possible solutions. Maybe you find a better one.
from melody.
Nice, the Centrifugo project looks really cool.
The queue solutions looks like it should work well for Melody, I'll have to take a closer look at it after work.
Thank you for the help!
from melody.
Thank you for your help @FZambia, as you can see in my code I took a different route than the infinite queue, instead I decided to dispatch the error handler and if the users wishes they can just increase MessageBufferSize
.
from melody.
Great! Thanks for your responsiveness:)
from melody.
Related Issues (20)
- hi,how to receive ping use js client ?
- Allow for synchronous broadcasts.
- Active Management? HOT 2
- it will be great!
- Is this still active? HOT 4
- Examples don't build
- Check returned errors before deferring Close() HOT 1
- why the comunication chan is sync, not async
- echo dependency broken (for chat-echo)
- A way to access credentials or authenticated service between driver and auth
- how get active sessions HOT 4
- how to keep a connecting, it always timeout after 1 minute HOT 1
- Comfortable with GoFiber framework? HOT 3
- Help request: How can I increase websocket read limit? HOT 2
- Example for implementing idle session timeout HOT 4
- Session Keys and access methods Get and Set is not concurrency safe HOT 3
- Question: With gorilla/websocket archived, does melody plan to move to nbio or some other plan? HOT 3
- support session.UnSet or delete HOT 2
- Question: Handle error in HandleMessage
- In current version there's no way to access informations about the hub structure 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 melody.