Comments (7)
When I wrote this I thought that this can prevent blocking when slow client does not read from socket fast enough. Your last solution will help with arbitrary throughput - but what if send
blocks and m
will grow more and more? I don't have strong understanding if this blocking possible or not.
from centrifugo.
client.send()
blocking shouldn't be an issue, since sendMessages
will always pull messages from c.messageChan
.
But if c.sess.Send(msg)
doesn't return, m
will keep growing. What do you think would be the optimal solution? A 10 second (configurable) timeout on c.sess.Send(msg)
?
from centrifugo.
For raw websocket connection there is SetWriteDeadline
(godoc) method available, but SockJS session has no such possibility.
from centrifugo.
We could wrap message sending in a function:
func (c *client) sendTimeout(msg string) error {
to := time.After(time.Second)
sent := make(chan error)
go func() {
sent <- c.sess.Send(msg)
}()
select {
case err := <- sent:
return err
case <- to:
return ErrSendTimeout
}
panic("unreachable")
return nil
}
The timeout length could be added to the client.
The thing that I don't really like about this solution is that we are spawning 2 goroutines to send a single message. Not a huge deal - goroutines are cheap, and it does seem like it is required.
I will make a PR proposal. It is a bit easier to discuss.
from centrifugo.
Maybe the best way right now - make buffer larger and make it configurable and see how it goes? And then after writing some benchmark tests it will be more clear what's the right solution to this?
from centrifugo.
I made a proposal in #23. After a few rewrites I think it is fairly unobtrusive, light on resources and rather easy to follow (except perhaps the ring queue implementation).
from centrifugo.
Looks very interesting! Not sure this line necessary as clean
method must be called anyway. There is old benchmark for Centrifuge - will try to run it after work to see memory and performance impact of these changes.
from centrifugo.
Related Issues (20)
- [feature] Precalculated presence stats counters in store HOT 8
- [feature] Add support for Ed25519 signature JWS HOT 2
- [bug] Channel Regex for Namespace cuased Null Pointer Exception HOT 2
- [feature] Add AMQP (RabbitMQ) support in async consumers API HOT 7
- [feature removal] Remove SockJS transport
- [feature] Improve health check by checking redis connection HOT 6
- [bug] The ID specified in XADD is equal or smaller than the target stream top item HOT 5
- [bug] getting "already subscribed" on page refresh HOT 3
- [feature] Silently Reject Publish Attempts on Proxied Channel Without Sending Client Errors HOT 4
- [question] What are the ways of decreasing the message payload? HOT 1
- [feature] Better error message when subscription token is used as connection token
- Unable To Connect With anonymous mode HOT 4
- [feature] serve admin interface via http2 HOT 4
- [feature] Send server time in initial connect response. HOT 2
- [question] Upgrading to 4.1.5 increase in response time HOT 3
- "Websocket Is Closed Before The Connection Is Established" - Web console error HOT 8
- [feature] Support for MessagePack Serialization HOT 2
- How to add multyple aud for a token in config file HOT 1
- [question] History StreamPosition and circular offsets. HOT 7
- [question] Centrifugo customization HOT 13
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 centrifugo.