Back

[SOLVED] Realtime connection not working

  • 0
  • Realtime
  • Apple
darShan
13 Aug, 2023, 11:44

Appwrite: 1.3.8 Apple SDK Version: 2.0.0

Implementation:

TypeScript
// After making sure that the user is signed in like:
let isLoggedIn = AppSdk.shared.isUserLoggedIn()

// where `isUserLoggedIn` is: 
func isUserLogedIn() async -> Bool {
    do {
        _ = try await account.get()
        return true
    } catch {
        return false
    }
}

/// User is logged in here.
let realtime = Realtime(AppSdk.shared.client)
let _ = realtime.subscribe(channel: "account") { (response) in
    print(String(describing: response))
}

Not only the account, but no events are delivered for any type of channel, example: documents.

I can successfully create a websocket connection via Postman for documents channel which is able to receive the response.

Url used in Postman: ws://192.168.1.7:1099/v1/realtime?project=projectID&channels[]=documents.

Also, there are no errors in the logcat so I believe the connection might be succesfull between the sdk and server but no data is received.

TL;DR
Realtime connection is not working in Swift code. The issue was resolved by following these steps: 1. Stop Docker Compose. 2. Turn off Docker Desktop. 3. Turn off the computer. 4. Take a break from work. 5. Reopen the project when returning to work. Other Appwrite endpoints are working fine, and account creation, sign-in, and password recovery are functioning properly. The Swift code implementation for Realtime connection looks correct based on the example in the documentation. To ensure all other Appwrite endpoints work in the app, a successful websocket connection was created using Postman for the "documents" channel.
safwan
13 Aug, 2023, 12:45

I'm not fluent in Swift so not sure what the issue is. This code looks correct based on the example code in docs.

Just to be sure all other appwrite emdpoints work in your app?

darShan
13 Aug, 2023, 13:18

Yepp, account creation, sign in, pass recovery, etc work fine.

darShan
13 Aug, 2023, 16:24

Closing this as it worked automatically after :

  1. docker compose stop
  2. Turn off Docker Desktop
  3. Turn off computer
  4. Take some break from work!

  1. Got back to work & reopened the project ๐Ÿ™‚
darShan
13 Aug, 2023, 16:26

[SOLVED] Realtime connection not working

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more