supabase / supabase-swift

A Swift client for Supabase

Home Page:https://supabase.com/docs/reference/swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RealtimeV2 does not handle connection failures

TiagoLira opened this issue · comments

Bug report

Describe the bug

I've just migrated to RealtimeV2, and it does not seem to handle disconnects.
On V1, when disconnecting the device from the internet, I would immediately get the "socket closed" messages, and it would reconnect as soon as the connection was back.
On V2, the socked closed message shows up much later, and it doesn't reconnect at all when the device is connected again.

Is there any additional steps I need to take? It seems strange as it worked on the previous version, and it's a fairly common need in real usage scenarios.

To Reproduce

Just connect to realtime database changes, and set the device to airplane mode (or turn off the internet otherwise).

System information

  • Version of supabase-swift: 2.3.1

Hi @TiagoLira thanks for opening issue.

Will check it out.

Hi @grdsdev,
When I try to connect to realtimeV1 instead (in version 2.3.1), I get constant connection errors, with the same code that I used in v1.1.0.
Do you know what might cause it? is there a workaround I can use on my side?

We are making a release of our app soon so I'm considering rolling back to supabase v1.1.0, if needed.

Here is the error:
Task <006837C2-EB52-4644-9C2C-36B65C9DB335>.<1> finished with error [-1011] Error Domain=NSURLErrorDomain Code=-1011 "There was a bad response from the server." UserInfo={NSErrorFailingURLStringKey=wss://gewyarhwmawzoajsodmf.supabase.co/realtime/v1/websocket?vsn=2.0.0&X-Client-Info=supabase-swift/2.3.1&Authorization=Bearer%20XXXXX, NSErrorFailingURLKey=wss://gewyarhwmawzoajsodmf.supabase.co/realtime/v1/websocket?vsn=2.0.0&X-Client-Info=supabase-swift/2.3.1&Authorization=Bearer%20XXXXXXX, _NSURLErrorWebSocketHandshakeFailureReasonKey=0, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalWebSocketTask <006837C2-EB52-4644-9C2C-36B65C9DB335>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <006837C2-EB52-4644-9C2C-36B65C9DB335>.<1>, NSLocalizedDescription=There was a bad response from the server.}

Hey @TiagoLira

It is weird that RealtimeV1 is failing with same code as before, I don't think there was any change in there since a couple of releases ago.

Regarding the better handling of connection error on RealtimeV2, I took a look at it and gonna make some improvements on there but I don't have an estimation of when it would be ready.

Just to give you some heads up, I'm joining Supabase to work full-time in 2 weeks (I'm currently only an external contributor), so expect faster fixes and responses after that.

Until there, I won't be able to work on this issue.

Thank you for the response @grdsdev.
After trying a few versions I found that the realtime V1 error first appears on 2.2.0
So we will be using 2.1.0 for now, that version is working well for us.