Repository navigation
fix: report error code 80017 for a closed connection - #1252
RaphaelFakhri wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe closed connection reason now uses the message "Connection closed", status 400, and error code 80017. A test checks those values in the closed state and when attaching a channel. ChangesClosed Connection Error
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change aligns the reported closed-connection error with the intended code and status. It is ready to merge after normal checks. Pre-merge checks |
|
There was a problem hiding this comment.
🟡 Changes recommended
Update the test to catch and assert the synchronous attach exception.
1 open finding
What changed in this PR
Updates closed-connection errors to use error code 80017 and HTTP status 400.
Changes:
- Updated the shared closed-connection error.
- Added regression coverage for closure and subsequent channel attachment.
| File | Summary |
|---|---|
lib/src/test/java/io/ably/lib/transport/ConnectionManagerClosedErrorTest.java |
Tests closed-connection error details; the attach assertion currently aborts because attach() throws synchronously. |
lib/src/main/java/io/ably/lib/transport/ConnectionManager.java |
Uses the corrected closed-connection error details. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ably.channels.get("closed_connection_attach").attach(new CompletionListener() { | ||
| @Override | ||
| public void onSuccess() {} | ||
|
|
||
| @Override | ||
| public void onError(ErrorInfo reason) { | ||
| attachError.set(reason); | ||
| } | ||
| }); |

Fixes #797
Description
When the connection is
closingorclosed, the SDK reportsErrorInfo("Can't attach when not in an active state", 200, 10000). Error code10000means "no error" in the Ably error list, and the HTTP status code is200. This error appears in two places:reasonof theclosingandclosedconnection state changes, and of thedetachedchannel state change that follows a close.attach()on a channel after the connection closes.This change reports
ErrorInfo("Connection closed", 400, 80017)instead. Code80017is the "connection closed" code in the Ably error list, and ably-js reports the same code and status code for theclosingandclosedstates.Testing
ConnectionManagerClosedErrorTestconnects through a mock transport that refuses connections, closes the connection, and assertscode80017 andstatusCode400 on theclosedstate change and on a laterattach(). It fails without the change (Expected: is <80017> but: was <10000>) and passes with it.Run it with:
Summary by CodeRabbit