Skip to content

Release v3.1.2: ignore unknown response fields, pubsub reconnect fixes - #20

Merged
winrid merged 2 commits into
mainfrom
fix-ws-reconnect
Nov 16, 2026
Merged

winrid merged 2 commits into
mainfrom
fix-ws-reconnect

Conversation

@winrid

@winrid winrid commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

FastComments Java SDK v3.1.2

Fix: responses with fields the client doesn't know threw IllegalArgumentException

The models rejected any response field missing from their schema. When the server added allowSimpleSSOAdmins to the widget config, PublicApi.getCommentsPublic threw The field allowSimpleSSOAdmins in the JSON string is not defined in the CustomConfigParameters properties for every tenant using Simple SSO, so the Android SDK couldn't load comments there.

The spec no longer marks models additionalProperties: false, so every model now keeps unknown fields (getAdditionalProperties(), getAdditionalProperty(name)) instead of throwing. A new server field no longer breaks older clients. core has a regression test (UnknownResponseFieldsTest).

Fix: pubsub LiveEventSubscriber stopped receiving live events after one failure

  • onFailure now reconnects. A failed connect and a dropped open socket both land there, not in onClosed, so before this nothing retried. The reconnect's onOpen fetches events missed in between.
  • Reconnects reuse urlIdWS, so they rejoin the same room instead of the raw urlId.
  • Backoff: full jitter over a 4s window that doubles to a 60s cap (0-4s, 0-8s, 0-16s, 0-32s, 0-60s), reset on open. A 4xx upgrade response is retried every 5 minutes.
  • Reconnects run on one idle-timeout daemon thread per subscriber instead of a new Timer thread per attempt.
  • close() closes the current socket after reconnects. onClosing and onClosed run on different OkHttp threads and now schedule a single reconnect between them, so no stray socket stays open delivering duplicate events.
  • The last event time is an AtomicLong, so concurrent events can't move it backwards and make a reconnect refetch events already delivered.

New LiveEventSubscriberReconnectTest (JUnit + MockWebServer, 7 tests).

New model fields

  • CustomConfigParameters: allowSimpleSSOAdmins, autoVerifySimpleSSOComments
  • TenantPackage: pricingCurrency, monthlyCostLocal, yearlyCostLocal
  • WebhookComment: badges (List<CommentUserBadgeInfo>)

No breaking changes.

Install

<dependency>
  <groupId>com.fastcomments</groupId>
  <artifactId>pubsub</artifactId>
  <version>3.1.2</version>
</dependency>

Full changelog: v3.1.1...v3.1.2

- onFailure (a failed connect, or a dropped socket from a server restart or network change) now reconnects; before, only onClosed did, so one failure ended live updates for good.
- The reconnect reuses urlIdWS, so it rejoins the same room instead of the raw urlId.
- Backoff is full jitter over a 4s window doubling to 60s, reset on open; a 4xx upgrade is retried every 5 minutes.
- One idle-timeout scheduler thread per subscriber instead of a Timer thread per reconnect.
- close() reaches the current socket after reconnects; only the newest connection may reconnect, and onClosing/onClosed schedule one reconnect between them (compareAndSet), so no stray socket delivers events twice.
- lastEventTime is an AtomicLong, so concurrent event times can't move it backwards.
The spec no longer marks models additionalProperties: false, so the regenerated models keep fields
they don't know instead of throwing. getCommentsPublic threw on the new allowSimpleSSOAdmins
customConfig field for Simple SSO tenants.

New fields: CustomConfigParameters.allowSimpleSSOAdmins and autoVerifySimpleSSOComments,
TenantPackage.pricingCurrency, monthlyCostLocal and yearlyCostLocal, WebhookComment.badges.
@winrid winrid changed the title pubsub: reconnect after failed connects and drops, with backoff Release v3.1.2: ignore unknown response fields, pubsub reconnect fixes Nov 16, 2026
@winrid
winrid merged commit 7b9f89e into main Nov 16, 2026
1 check passed
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.

1 participant