Skip to content

Conversation

@tcheeric
Copy link
Owner

Summary

This pull request refactors WebSocket handling to address connection timeout issues and enhance integration test robustness.

What changed?

  • Replaced nostr-rs-relay with dockurr/strfry for integration tests.
  • Introduced configurable WebSocket idle timeout (nostr.websocket.max-idle-timeout-ms).
  • Added debug and error logging to diagnose timeout issues during test execution.
  • Simplified WebSocket client initialization with a new public constructor for timeout parameter configuration.
  • Updated integration tests for dynamic relay configuration and improved retry logic.
  • Added changelog maintenance instructions to AGENTS.md.

BREAKING

None.

Review focus

  • Is the new configurable WebSocket idle timeout appropriate?
  • Are the integration test changes clear and effective for improving reliability?

Checklist

  • Scope ≤ 300 lines (or split/stack)
  • Title is verb + object (e.g., “Refactor auth middleware to async”)
  • Description links the issue and answers “why now?”
  • BREAKING flagged if needed
  • Tests/docs updated (if relevant)

tcheeric and others added 12 commits October 6, 2025 00:53
Complete Changes from Version 0.2.2 to 0.5.1
Add Sonatype Central publishing credentials and refactor event handling
Update Maven configuration for central publishing
Update Maven settings and consolidate API improvements
…rs to StandardWebSocketClient

Added a new public constructor to StandardWebSocketClient that accepts timeout
parameters directly, eliminating the need for reflection-based configuration.

New constructor:
  public StandardWebSocketClient(String relayUri, long awaitTimeoutMs, long pollIntervalMs)

This allows callers to:
- Configure timeouts programmatically without Spring @value annotations
- Create StandardWebSocketClient outside of Spring DI context
- Avoid reflection hacks for timeout configuration

Version bumped from 1.0.1 to 1.1.0 (minor version) per semver as this adds
new public API while maintaining backward compatibility.

Benefits:
- Cleaner API for programmatic configuration
- No reflection required
- Better testability
- Aligns with constructor injection pattern

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added debug and error logging to StandardWebSocketClient to help diagnose
timeout configuration issues:

- Log actual timeout values when StandardWebSocketClient is created
- Log timeout values being used when waiting for relay response
- Include configured timeout values in error message when timeout occurs

This helps verify that:
1. The constructor is being called with correct timeout values
2. The timeout values are being used in await() calls
3. The actual timeout duration matches the configured value

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add instructions for maintaining CHANGELOG.md following Keep a Changelog
format with semantic versioning best practices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The StandardWebSocketClient now configures the underlying WebSocketContainer
with a default 1-hour max session idle timeout. This prevents premature
connection closures when Nostr relays have periods of inactivity between
messages (e.g., after EOSE when waiting for new events).

Configuration:
- nostr.websocket.max-idle-timeout-ms (default: 3600000, 1 hour)
- Set to 0 for no timeout

The fix uses ContainerProvider.getWebSocketContainer() to obtain the
container, configures setDefaultMaxSessionIdleTimeout(), then passes
the configured container to Spring's StandardWebSocketClient constructor.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Release 1.1.1 with fix for WebSocket idle timeout configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…obustness

Replaced nostr-rs-relay with dockurr/strfry for integration tests, addressing timeout and crash issues. Enhanced WebSocket client retry logic, added configurable relay port, and included additional wait for indexing. Updated test setup for dynamic relay configuration and removed unused response comparison logic.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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".

Comment on lines +52 to +54
.withClasspathResourceMapping(
"strfry.conf", "/etc/strfry.conf", BindMode.READ_ONLY)
.withTmpFs(Map.of("/app/strfry-db", "rw"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provide strfry.conf classpath mapping for relay container

The new Testcontainers relay setup maps strfry.conf into the container (withClasspathResourceMapping("strfry.conf", ...)), but the repository has no such resource under src/test/resources (e.g., find . -name strfry.conf returns nothing). When the container starts, Testcontainers fails to resolve the host path or the relay launches without its required config, so integration tests abort before running. Please add the config file or drop the mapping so the strfry container can start.

Useful? React with 👍 / 👎.

…strfry fixes

Marked integration tests as resolved with all 24 passing using strfry relay. Documented issues with nostr-rs-relay and provided solutions, including custom strfry configuration, indexing delay, and relay-agnostic assertions. Enhanced troubleshooting section with detailed resolutions for common test issues.
@tcheeric tcheeric merged commit 2e5b6fe into develop Dec 25, 2025
1 of 2 checks passed
@tcheeric tcheeric deleted the fix/1.1.1 branch December 25, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants