Comments (6)
@PatrickPijnappel what does your web socket code look like? We're probably missing a hop somewhere
from websocket-kit.
@0xTim Basically this:
self.queue.async {
// (…)
webSocket.onBinary { [weak self] _, data in // Called from arbitrary queue
guard let self = self else { return }
// (…)
}
}
from websocket-kit.
What is self in this instance and queue? Im assuming the web socket is being created outside of the queue closure?
from websocket-kit.
self
is a custom (final) class and queue
is a serial DispatchQueue
. The web socket is being created elsewhere on another queue using effectively
WebSocket.connect(to: url, on: app.eventLoopGroup.next()) { webSocket in
queue.async { self.webSocket = webSocket }
}
from websocket-kit.
@PatrickPijnappel ah ok, I misread this initially.
Setting the WS callbacks must be done on the Websocket's EventLoop
. We assumed this was the case before but had no way to enforce this at a compiler level before Sendable
. Doing it off the event loop might have worked but could easily caused crashes before and for us to be Sendable
compliant we have to enforce it.
One workaround might be to wrap your calls in
websocket.eventLoop.execute {
websocket.onBinary {
// ...
}
}
That should enforce that the mutations are done on the correct event loop, but mixing concurrency, event loops and dispatch queues like this is always going to cause issues
from websocket-kit.
@0xTim Ah i see, thank you!
from websocket-kit.
Related Issues (20)
- CI fails when run from PR HOT 1
- It just doesn't work! HOT 26
- Example of using websocket-kit with system proxy? HOT 2
- Async/Await Backward Compatibility HOT 1
- add iOS platform in Package.swift
- NIOAtomic is deprecated
- No support for WatchOS HOT 1
- Support needed when using WebSocket Kit as client HOT 3
- `HTTPInitialRequestHandler` should not add a `Content-Type` header
- CocoaPods Support? HOT 2
- NIOCore/NIOLoopBound.swift:120: Precondition failed in 2.14.0 HOT 7
- WSS Proxy Setup Broken HOT 2
- crashed HOT 3
- Should be able to force close the WebSocket HOT 2
- `pingInterval` should just force close the connection if the server doesn't pong HOT 3
- TLS test with a websocket-kit server and client
- query part is chopped from the URL
- Massive 100% CPU load when receiving multi frame WebSocket message HOT 3
- Update Client code to remove warnings 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 websocket-kit.