-
-
Notifications
You must be signed in to change notification settings - Fork 96
Force default WebSocket port to prevent :0 errors #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughSocketNotifier.init now always builds a WebSocket URL with an explicit port and scheme. It derives the scheme from the secure flag, chooses default ports (443/80) when port is null or 0, and appends the token query if present. No other logic or public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant SocketNotifier
participant WS as WebSocket Server
App->>SocketNotifier: init(secure, hostname, port, token)
rect rgba(200,230,255,0.25)
note right of SocketNotifier: Build URL with explicit scheme and port
SocketNotifier->>SocketNotifier: scheme = secure ? "wss" : "ws"
SocketNotifier->>SocketNotifier: socketPort = (port == null || port == 0) ? (secure ? 443 : 80) : port
SocketNotifier->>SocketNotifier: url = scheme + "://" + hostname + ":" + socketPort + [ "?token=..." ]
end
SocketNotifier->>WS: Connect(url)
WS-->>SocketNotifier: Upgrade/Establish
SocketNotifier-->>App: Ready / connected
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/lib/models/communicator.dart (1)
120-121
: Do not log the auth token; redact it.Token in debug logs is a credential leak.
- debugPrint("Initializing socket to $url"); + final logUri = + token == null ? uri : uri.replace(queryParameters: {'token': 'REDACTED'}); + debugPrint("Initializing socket to $logUri");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/lib/models/communicator.dart
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/**/*.dart
📄 CodeRabbit inference engine (app/AGENTS.md)
app/**/*.dart
: Use standard Dart formatting viaflutter format
for all Dart source files
Keep Dart files under 300 lines where possible
Files:
app/lib/models/communicator.dart
🔇 Additional comments (1)
app/lib/models/communicator.dart (1)
115-119
: Confirm hostname semantics (no scheme/port/path).Found call at app/lib/pages/connect_page.dart:44–46 (ref.read(socketProvider.notifier).init(hostname, port)) — verify that
hostname
is a bare host (no "http(s)://", no ":port", no path). If callers can pass "host:port" or a full URL, either sanitize/normalize the input at the call sites or update communicator.init to parse/construct the URI (use Uri.parse/Uri(scheme:..., host:..., port:...) or explicitly strip scheme/port/path) to avoid producing invalid URLs.
The web UI failed to connect to the WebSocket server when no port was specified, because the client appended an invalid
:0
port. This is fixed by explicitly using the default port when no port is provided:443
forwss://
and80
forws://
.Linked issue: rikulo/socket.io-client-dart#222
To support more complex setups with custom public port, it would require to be able to specify a custom port or even let the user set the public address manually of both panel and websocket
Summary by CodeRabbit