Add configurable WebSocket buffer sizes for large Nostr events#505
Merged
Add configurable WebSocket buffer sizes for large Nostr events#505
Conversation
Configure WebSocketContainer with larger text/binary message buffer sizes (default 1MB each) to handle NIP-60 wallet state events and other large Nostr events that exceed default buffer sizes. Buffer sizes are now configurable via system properties: - nostr.websocket.max-idle-timeout-ms (default: 3600000) - nostr.websocket.max-text-message-buffer-size (default: 1048576) - nostr.websocket.max-binary-message-buffer-size (default: 1048576) This fixes 1009 "message too big" errors that caused WebSocket disconnections when receiving large events from relays. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Projects updated: - nostr-java: 1.2.1 → 1.3.0 (minor) - All modules updated to match parent version Changes include: - Added configurable WebSocket buffer sizes for large Nostr events - Improved Kind enum with safer lookup methods - Fixed thread-safety in WebSocket client send() - Fixed fail-fast deserialization in KindFilter Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…StandardWebSocketClient
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aed3adfaff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
...ient/src/test/java/nostr/client/springwebsocket/StandardWebSocketClientMultiMessageTest.java
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable WebSocket container buffer sizes for handling large Nostr events and bumps the project to version 1.3.0, along with additional tests for StandardWebSocketClient.
Changes:
- Configure
StandardWebSocketClient’s underlyingWebSocketContainerwith customizable idle timeout and text/binary buffer sizes via system properties, with 1 MB defaults for large Nostr events (e.g., NIP-60). - Add
StandardWebSocketClientMultiMessageTestto verify accumulation of multiple relay messages, termination handling (EOSE/OK), and timeout behavior; retain and reuse existing timeout/subscription tests. - Bump the root and module POM versions from
1.2.1to1.3.0and document the 1.3.0 release inCHANGELOG.md.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
pom.xml |
Bumps the parent artifact version to 1.3.0, defining the new release version. |
nostr-java-util/pom.xml |
Aligns the util module with parent version 1.3.0. |
nostr-java-id/pom.xml |
Aligns the id module with parent version 1.3.0. |
nostr-java-examples/pom.xml |
Aligns the examples module with parent version 1.3.0. |
nostr-java-event/pom.xml |
Aligns the event module with parent version 1.3.0. |
nostr-java-encryption/pom.xml |
Aligns the encryption module with parent version 1.3.0. |
nostr-java-crypto/pom.xml |
Aligns the crypto module with parent version 1.3.0. |
nostr-java-base/pom.xml |
Aligns the base module with parent version 1.3.0. |
nostr-java-api/pom.xml |
Aligns the API module with parent version 1.3.0. |
nostr-java-client/pom.xml |
Aligns the client module with parent version 1.3.0. |
nostr-java-client/src/main/java/nostr/client/springwebsocket/StandardWebSocketClient.java |
Adds default text/binary buffer size constants, extends createSpringClient to read idle-timeout and buffer sizes from system properties, configures the WebSocketContainer accordingly, and logs the effective settings. |
nostr-java-client/src/test/java/nostr/client/springwebsocket/StandardWebSocketClientMultiMessageTest.java |
New tests verifying that StandardWebSocketClient.send accumulates multiple EVENTs until EOSE, completes immediately on OK, and times out when EOSE never arrives. |
CHANGELOG.md |
Adds a 1.3.0 entry documenting configurable WebSocket buffer sizes and (re)lists earlier Kind-related behavior, but with some property-name and duplication issues called out in review comments. |
nostr-java-client/src/main/java/nostr/client/springwebsocket/StandardWebSocketClient.java
Show resolved
Hide resolved
...ient/src/test/java/nostr/client/springwebsocket/StandardWebSocketClientMultiMessageTest.java
Show resolved
Hide resolved
...ient/src/test/java/nostr/client/springwebsocket/StandardWebSocketClientMultiMessageTest.java
Show resolved
Hide resolved
...ient/src/test/java/nostr/client/springwebsocket/StandardWebSocketClientMultiMessageTest.java
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
6 tasks
[WIP] Update configurable WebSocket buffer sizes based on feedback
[WIP] Apply feedback from review on configurable WebSocket buffer sizes
[WIP] Update configurable WebSocket buffer sizes for Nostr events
[WIP] Update configurable WebSocket buffer sizes for Nostr events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces configurable WebSocket buffer sizes to handle large Nostr events, such as NIP-60 wallet state events, which previously exceeded default buffer sizes and caused disconnections. Defaults are set to accommodate typical large event sizes while remaining customizable via system properties.
Type of change
fix- Bug fix (non-breaking)feat- New feature (non-breaking)refactor- Code change that neither fixes a bug nor adds a featuredocs- Documentation onlytest- Adding or updating testsperf- Performance improvementchore- Build, CI, or tooling changesWhat changed?
nostr.websocket.max-idle-timeout-ms(default: 1 hour)nostr.websocket.max-text-message-buffer-size(default: 1MB)nostr.websocket.max-binary-message-buffer-size(default: 1MB)1.3.0.Breaking changes
None.
Testing
mvn testmvn verify(requires Docker)Review focus
Checklist
type(scope): description