zhangshenghang opened a new pull request, #12716:
URL: https://github.com/apache/seatunnel/pull/12716

   ### Purpose of this pull request
   
   This PR fixes https://github.com/apache/seatunnel/issues/12713.
   
   `WebSocketSourceClient` records connection failures in a `fatalError` field 
that the reader rethrows on every `pollNext()` via `rethrowFatalIfNeeded()`. 
The field was never cleared: `onOpen()` reset the reconnect counter but left 
any error recorded by the previous connection in place.
   
   Failure sequence with default options (`open_messages` configured, 
`enable_reconnect = true`, `poll_timeout_ms = 1000 < reconnect_interval_ms = 
3000`):
   
   1. The server drops the connection right after the handshake; 
`webSocket.send()` returns `false` while sending the open messages, so 
`fatalError` is set to `SEND_MESSAGE_FAILED`.
   2. `onClosed`/`onFailure` triggers the automatic reconnect.
   3. The reconnect succeeds and data flows again.
   4. The next `pollNext()` rethrows the **stale** error of the dead connection 
and kills the fully recovered task — in the default configuration even before 
the first reconnect attempt fires, so `enable_reconnect` cannot save the task 
at all.
   
   The fix clears the recorded error when a connection is (re)established: the 
new connection invalidates everything recorded for the old one. This matches 
the existing asymmetry in `onOpen()`, which already reset the reconnect counter 
but not the error.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, bug fix: with `open_messages` configured and a transient disconnect 
right after the handshake, a streaming task now recovers via the (default) 
auto-reconnect instead of failing with a `SEND_MESSAGE_FAILED` error from the 
dead connection.
   
   ### How was this patch tested?
   
   - New unit test 
`WebSocketSourceClientFatalErrorTest.shouldClearFatalErrorRecordedByPreviousConnectionWhenReconnectSucceeds`
 drives the listener callbacks against stub sockets (no live server, fully 
deterministic): it asserts the stale error is reported while current and no 
longer reported after a successful reconnect. Verified the test **fails** on 
the unfixed code and passes with the fix.
   - Full connector module test suite passes (`mvn -pl 
seatunnel-connectors-v2/connector-websocket test`, 36 tests).
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   * [x] If you are contributing the connector code, please check that the 
following files are updated:
     1. No new connector is added, so `plugin-mapping.properties`, 
`seatunnel-dist/pom.xml`, label-scope-conf and e2e updates do not apply


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to