-
Notifications
You must be signed in to change notification settings - Fork 27
Description
π Reproduction steps
- Create two Clients, and for each, create a Realtime.
- Attempt to subscribe on each, possibly to different things.
Explicit example:
val clientA = Client().setEndpoint("http://localhost:8080/v1").setProject("1234")
val clientB = Client().setEndpoint("http://localhost:8088/v1").setProject("5678")
val realtimeA = Realtime(clientA).subscribe(...)
val realtimeB = Realtime(clientB).subscribe(...)
π Expected behavior
It should create one socket per Client, or at most per endpointRealtime.
If I have multiple Client objects connected to different backends, I should be able to have a separate socket to each.
Simply changing
class Realtime ... {
private companion object {
private var socket: RealWebSocket? = null
to
private val sockets: Map<String, RealWebSocket> = mutableMapOf()
and making appropriate thread-safe changes to the few places sockets are created/destroyed would address this.
π Actual Behavior
It shares a single socket across all Client/Realtimes, as it puts the socket on a private companion object.
Thus when I create realtimeB and call subscribe, it will close the socket, and create a new socket to localhost:8088 but try to merge all the requests for updates together. It's possible there are different users on each backend, etc.
π² Appwrite version
Version 1.8.x
π» Operating system
Linux
π§± Your Environment
This is Kotlin using io.appwrite:sdk-for-android:11.4.0
Note that this is an unusual scenario to have multiple clients to multiple backends, but I'm designing a highly-resilient, client-driven multiple-backend project that can keep multiple backends in sync, so it's a requirement for my project.
π Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
π’ Have you read the Code of Conduct?
- I have read the Code of Conduct