Comments (10)
@Zyphrax I have created sample app here https://github.com/mikina/TelegraphSocket
from telegraph.
I've fixed the slow websocket parsing in commit ed55f1a
On my Mac mini, parsing the output1.json
payload went from 1 minute 20 sec. to 80 milliseconds !
I'll probably release a new Telegraph version tomorrow.
I have a few more fixes that I want to add to the new version as well.
from telegraph.
Unfortunately WebSocket communication is a bit limited in Telegraph. I haven't implemented the full spec. However a payload of 1MB should work.
Do you have a small example app for me to test this?
from telegraph.
@mikina Thank you. The WebSocket framing protocol is optimized to handle messages of different sizes. WebSocket frames look like this:
// Base Framing Protocol (https://tools.ietf.org/html/rfc6455 - 5.2)
//
// |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
// +-+-+-+-+-------+-+-------------+-------------------------------+
// |F|R|R|R| opcode|M| Payload len | Extended payload length |
// |I|S|S|S| (4) |A| (7) | (16/64) |
// |N|V|V|V| |S| | (if payload len==126/127) |
// | |1|2|3| |K| | |
// +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
// | Extended payload length continued if payload len == 127 |
// + - - - - - - - - - - - - - - - +-------------------------------+
// | | Masking-key, if MASK set to 1 |
// +-------------------------------+-------------------------------+
// | Masking-key (continued) | Payload Data |
// +-------------------------------- - - - - - - - - - - - - - - - +
// : Payload Data continued ... :
// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
// | Payload Data continued ... |
// +---------------------------------------------------------------+
I think Telegraph might contain a
from telegraph.
Awesome! @Zyphrax let me know if I can help more
from telegraph.
Ok, I found two bugs:
- Telegraph has a few helpers to convert
UInt16
,UInt32
andUInt64
values to anUInt8
array. TheUInt64
helper was unnecessarily complex and didn't seem to return the correct array. - The
WebSocketMessage+Write
class has a small issue where payload sizes aboveInt16.max
would be considered a large payload. That is not according to spec, it should beUInt16.max
instead ofInt16.max
.
I'll commit these changes after this. You can use the HEAD version of Telegraph by specifying this in your Podfile:
pod 'Telegraph', :git => 'https://github.com/Building42/Telegraph.git'
The web socket message no longer fails, but for some reason it is reallllllly slow. It takes a bit over 1 minute on my machine to send the output1.json
message. So that's the next
from telegraph.
The performance issue seems to be caused by the WebSocket frame parser. I have to rework the part that processes the payload a bit. I'll keep you posted.
from telegraph.
Thanks for the information and thank you for taking care of this 😊
from telegraph.
Excellent news
from telegraph.
Fixed in 0.17
from telegraph.
Related Issues (20)
- Cache files when serving a directory HOT 1
- NSURLErrorDomain (code = -1202) HOT 1
- Swift Compiler Warning (Xcode 13) - Using Class is deprecated use AnyObject instead HOT 1
- Supporting Multipart File Upload Request HOT 1
- Protocol 'WebSocket' as a type cannot conform to 'Equatable' HOT 1
- Sending WebSocket messages HOT 1
- Add remote/local endpoint information into HTTP request routing handlers HOT 2
- How to proxy requests? HOT 1
- How to upload file to server ? HOT 1
- Assistance with route formatting
- Xcode 14 beta 6 - Redefinition of enumerator error HOT 3
- MacOS Example Needed Modifications HOT 2
- IOS Test App provided does not allow connection from outside device HOT 1
- SecPKCS12Import should not be called on the main thread HOT 3
- Using with command line tool HOT 1
- Expose WebSocketConnections HOT 1
- Xcode 14.1/2 - Redefinition of enumerator error HOT 8
- HEAD method doesn't seem to work HOT 2
- Deprecated SecureTransport dependency HOT 1
- serverHTTP.serveDirectory(Bundle.main.url(forResource: "Demo", withExtension: nil)!) can not runing 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 telegraph.