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)
- Compilation fails on alpine 3.19.1
- Add support for icon URL in NIP-11 document
- access reports HOT 1
- What happened to the Docker images? HOT 1
- SIGTERM
- Search by tag and tag substring returns no results
- A question regarding the sync command HOT 2
- Up-to-date docker image in dockerhub HOT 1
- Cron deletes events that are not expired HOT 1
- Importing events from another relay using .jsonl import HOT 4
- Feature: retention period HOT 5
- Feature request: NIP-45 Event Count HOT 6
- Build Error HOT 6
- Favicon for relay HOT 1
- Cryptic error messages returned in OK messages HOT 1
- logging controls not documented/working
- docker-compose not working HOT 4
- REQ limit is too low HOT 1
- strify crashes on start HOT 2
- OSX build error
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.