Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ably ios client closes connection 'WS:0x6000000befc0 websocket did disconnect (code 1000) (null)' #655

Closed
shoaibahmedqureshi opened this issue Nov 29, 2017 · 9 comments

Comments

@shoaibahmedqureshi
Copy link

shoaibahmedqureshi commented Nov 29, 2017

Hi ,
I am new to ably and running into an issue while receiving messages . It works fine initially and recieves messages as per normal but after receiving too many messages at some point socket gets disconnected and logs this message 'WS:0x6000000befc0 websocket did disconnect (code 1000) (null)' and then it no longer receives any message . something that is interesting is that 'ablyRealtime!.connection.state == ARTRealtimeConnectionState.connected' still returns true. How to prevent this from happening ?

Following method shows my configuration settings .

private func setClientOptions(token: String?) {
    if token != nil {
        options = ARTClientOptions(token: token!)
    }
    else {
        options = ARTClientOptions(key: ablyKey!)
    }
    //options.auth.authCallBack = nil
    options!.channelRetryTimeout = 100
    options!.disconnectedRetryTimeout = 200
    options!.autoConnect = true
    options!.queueMessages = false
    options!.logLevel = ARTLogLevel(rawValue: 1)!
}
@tcard
Copy link
Contributor

tcard commented Dec 1, 2017

@shoaibahmedqureshi Hi. Can you confirm commit f5fc053 fixes it? Please reopen the issue if it doesn't.

@shoaibahmedqureshi
Copy link
Author

shoaibahmedqureshi commented Dec 1, 2017

@tcard Is this committed reflected when i install using cocoa pods using line "pod 'Ably', '~> 1.0' " in pod file as I reinstalled it using cocoa and checked it the issue is still reproducing for me and is not fixed.

@tcard
Copy link
Contributor

tcard commented Dec 1, 2017

@shoaibahmedqureshi No, sorry, you have to do something like:

pod 'Ably', :git => 'https://github.com/ably/ably-ios.git', :commit => 'f5fc0531912049bdadecc451b3b8429290880cf3'

@tcard
Copy link
Contributor

tcard commented Dec 1, 2017

Once we confirm it's fixed we can do a release, and then ~> 1.0 will work. Thanks for your help!

@shoaibahmedqureshi
Copy link
Author

I am still facing it despite above mentioned commit. please refer to logs.

myTrackee[22130:941155] DEBUG: (ARTRealtimeChannel.m:550) R:0x604000188f00 C:0x600000188610 received channel message 15 - Message
2017-12-02 05:21:42.807297+0500 myTrackee[22130:941155] DEBUG: (ARTWebSocketTransport.m:256) R:0x604000188f00 WS:0x60401babc020 websocket did disconnect (code 1000) (null)
2017-12-02 05:21:42.829078+0500 myTrackee[22130:941155] DEBUG: (ARTRealtime.m:328) R:0x604000188f00 realtime state transitions to 3 - Disconnected
2017-12-02 05:21:42.852442+0500 myTrackee[22130:941155] DEBUG: (ARTRealtimeChannel.m:494) channel state transitions to 6 - Failed
2017-12-02 05:21:42.879223+0500 myTrackee[22130:941155] DEBUG: (ARTRealtimeChannel.m:494) channel state transitions to 6 - Failed

@marvin-yorke
Copy link

marvin-yorke commented Dec 6, 2017

Hi folks. FYI, we also experience the same problem. Implemented solution seems reasonable, going to try to build with provided commit and verify

@marvin-yorke
Copy link

ok @tcard, we have tested your solution and it seems to work. Thanks! Here's the log

2017-12-06 13:32:10.979 [Debug] [ARTLogAdapter.swift:25] > (ARTWebSocketTransport.m:256) R:0x174193ce0 WS:0x1742ab580 websocket did disconnect (code 1000) (null)
2017-12-06 13:32:10.988 [Debug] [ARTLogAdapter.swift:25] > (ARTRealtime.m:328) R:0x174193ce0 realtime state transitions to 3 - Disconnected
2017-12-06 13:32:27.518 [Debug] [ARTLogAdapter.swift:25] > (ARTRealtime.m:328) R:0x174193ce0 realtime state transitions to 1 - Connecting
2017-12-06 13:32:27.531 [Debug] [ARTLogAdapter.swift:25] > (ARTWebSocketTransport.m:110) R:0x174193ce0 WS:0x1742ae760 websocket connect with key
2017-12-06 13:32:27.535 [Debug] [ARTLogAdapter.swift:25] > (ARTWebSocketTransport.m:180) R:0x174193ce0 WS:0x1742ae760 url wss://realtime.ably.io:443/?key=<redacted>&echo=false&format=msgpack&resume=<redacted>&connectionSerial=277&v=1.0&lib=ios-1.0.9
2017-12-06 13:32:27.542 [Info] [ARTLogAdapter.swift:27] > Reachability: stopped listening for host realtime.ably.io
2017-12-06 13:32:27.550 [Info] [ARTLogAdapter.swift:27] > Reachability: started listening for host realtime.ably.io
2017-12-06 13:32:29.042 [Debug] [ARTLogAdapter.swift:25] > (ARTWebSocketTransport.m:251) R:0x174193ce0 WS:0x1742ae760 websocket did open
2017-12-06 13:32:29.069 [Debug] [ARTLogAdapter.swift:25] > (ARTWebSocketTransport.m:343) R:0x174193ce0 WS:0x1742ae760 websocket did receive data

@shoaibahmedqureshi could you please double-check that you are indeed using the correct commit to build against? I mean just open the ARTWebSocketTransport.m file in your Pods directory and check whether it contains the changes from f5fc053

@tcard
Copy link
Contributor

tcard commented Dec 6, 2017

Thanks @marvin-yorke.

But according to the latest logs provided by @shoaibahmedqureshi, she/he now seems to be having a separate issue. The connection moves to the Disconnected state as expected, which should then trigger a reconnection (ie. move to Connecting) but instead some channels move to the Failed state.

@shoaibahmedqureshi Could you log what's the error causing the transition to Failed on those channels? Something like this should do it:

let ably = ARTRealtime(...)
let channel = ably.channels.get("<your channel>")
channel.on(.failed) { change in
    print("channel \(channel.name) moved to failed, reason: \(change.reason)")
}

@marvin-yorke
Copy link

@tcard quick update: I've tried turning off message queueing (for reason different than the current topic), while using provided fix. And now I see the same problem as @shoaibahmedqureshi. Channels move to failed state even though network condition is perfect. Connection moves to disconnected, then to connected again, but failed channels cannot be restored automatically. If message queue is on, everything seems to work as expected under same conditions.

Not sure if it's directly related to this issue, but @shoaibahmedqureshi seems to also have message queue off in their settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants