Comments (6)
Or perhaps it is allowed to send multiple nostr messages in a single websocket message payload? I did not think this was the case, but the NIP-01 document is a bit vague on the details.
from strfry.
In websockets terminology, "per-message" means that you can optionally compress some messages and not others. Each message has a flag that says whether it's compressed, basically. This is partly because it's not worthwhile to compress small messages, and also partly because of security reasons, where mixing attacker-provided data with secret data in the same compression context can leak the secret data (ie see the CRIME attack: https://security.stackexchange.com/questions/19911/crime-how-to-beat-the-beast-successor/19914#19914 )
The actual compression is specified as the DEFLATE (aka LZ77) algorithm (basically gzip without some headers and checksums).
When the websocket connection is started, clients and servers negotiate how the compression will happen. Either each message can use an empty DEFLATE buffer, or the buffer can be populated by previous messages over the same websocket connection. This is called a "sliding window" and achieves cross-message compression. Whoever told you this is not possible hasn't read the websocket compression RFC. It's is all described in detail here:
https://www.rfc-editor.org/rfc/rfc7692#section-7.1
The websocket sliding window system is not perfect though. First of all there are much better algorithms nowdays (ie zstd). The sliding window is limited to 32k max, and there is no way to pre-populate a dictionary and/or use a static dictionary for each message. Still, IMO the calculus for nostr is pretty clear that this is beneficial, which is why strfry enables it by default. You can see in the logs how effective the compression is for each connection.
from strfry.
Cool thanks! I read a bit more and learned that the "context takeover" headers are the relevant ones. I was a bit confused. Thanks for the answer!
from strfry.
No worries! FWIW, I find the *_context_takeover terminology confusing too. I think that RFC could've benefited from some significant editorial work.
from strfry.
Yes I was testing strfry
but I was sending the server_no_context_takeover
extension parameter. The compression was still pretty good (according to the helpful strfry
logs). I am excited to see what happens if I don't send the server_no_context_takeover
extension parameter. I need to figure out how to handle the received messages though. Anyways, thanks again for taking the time to answer my silly question.
PS. I was playing around with quadrable in the strfry
directory:
quadb --db=./strfry-db dumpTree
Pretty cool stuff!
from strfry.
Thanks! The merkle tree stuff is going to have some pretty fun applications, I'm looking forward to writing up some more details on that. :)
For testing the sliding windows, I mostly use web browsers since this isn't a widely implemented feature for command-line clients. However, pretty much every browser negotiates the full window. The easiest way to see the effect is to do a query with sliding window enabled in the strfry config, then turn it off and do the same query. I think you have to restart the relay for this currently. That's not an inherent limitation, I just haven't got around to making that hot-changeable.
from strfry.
Related Issues (20)
- Question: How can I most efficiently stream from many relays? HOT 5
- strfry stream segfaults HOT 2
- Implement nip 42 client authentication HOT 8
- Please provide an api for "Read Policy Plugins" HOT 3
- "bad event id" on actually valid object. HOT 12
- Parser for x-forwarded-for does not work with IPv6 or multiproxy HOT 3
- Build error on latest master HOT 2
- nip-11 pubkey as bech32 should be rejected or warned or well documented to avoid HOT 2
- Using a Reverse Proxy like e.g. NGINX HOT 3
- strfry distribution channels HOT 2
- Write policy applied to sync? HOT 1
- Large database performance HOT 12
- Document all the secret strfry commands HOT 1
- Can I log the reason for "Request ID too long"? HOT 1
- REQ plugin HOT 1
- Compilation Errors HOT 2
- Trying to install HOT 2
- Dockerfile build fails HOT 1
- MDB_MAP_FULL: Environment mapsize limit reached HOT 5
- Work to change database HOT 2
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 strfry.