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

Unable to connect to Ably #22

Closed
stannedelchev opened this issue Sep 18, 2015 · 3 comments
Closed

Unable to connect to Ably #22

stannedelchev opened this issue Sep 18, 2015 · 3 comments

Comments

@stannedelchev
Copy link
Contributor

I'm using the following code to connect to Ably, but the connection timeouts every time I run the app.
The .on() handler receives a .Connecting, 15 seconds later a .Failed state, with a nil errorReason.
The key is taken from jsbin.ably.io, but any key from my ably.io apps is broken as well.

let logger = ARTLog()
logger.logLevel = ARTLogLevel.Verbose

let clientOptions = ARTClientOptions(key: "xVLyHw._fgLgQ:ImldB3D2L1Is0ve-")
clientOptions.authOptions.clientId = "stan"
clientOptions.authOptions.logger = logger

self.realtime = ARTRealtime(options: clientOptions)
self.realtime.eventEmitter.on { (ARTRealtimeConnectionState state) -> Void in
    if state == .Failed {
        let reason = self.realtime.connectionErrorReason()
        println("Message: \(reason.message)")
        println("Description: \(reason.description)")
    }

    println("State rawvalue: \(state.rawValue)")
}

Log:

2015-09-18 20:32:49.084 demo-ios[2896:19740] VERBOSE: ARTAUTH creating signed token request callback
2015-09-18 20:32:49.085 demo-ios[2896:19740] VERBOSE: ARTAUTH signed token request callback called
2015-09-18 20:32:49.085 demo-ios[2896:19740] DEBUG: ARTAuth: query time is being used
State rawvalue: 1
2015-09-18 20:32:51.173 demo-ios[2896:19740] SocketRocket: In debug mode.  Allowing connection to any root cert
Message: nil
Description: <ARTErrorInfo: 0x7fa665800600>
State rawvalue: 7

Call stack:

Thread 1Queue : com.apple.main-thread (serial)
#0  0x0000000103fdc0fd in demo_ios.ChatViewController.(viewDidLoad (demo_ios.ChatViewController) -> () -> ()).(closure #1) at /Users/stan/Desktop/projects/ably/demo-ios/demo-ios/ChatViewController.swift:34
#1  0x0000000103fdc51f in reabstraction thunk helper from @callee_owned (@unowned C.ARTRealtimeConnectionState) -> (@unowned ()) to @callee_unowned @objc_block (@unowned C.ARTRealtimeConnectionState) -> (@unowned ()) ()
#2  0x000000010416dc57 in -[ARTRealtime transition:] at /Users/stan/Desktop/projects/ably/demo-ios/Pods/ably/ably-ios/ARTRealtime.m:1054
#3  0x000000010416f06a in -[ARTRealtime onConnectTimerFired] at /Users/stan/Desktop/projects/ably/demo-ios/Pods/ably/ably-ios/ARTRealtime.m:1221
#4  0x000000010416dea6 in __32-[ARTRealtime startConnectTimer]_block_invoke at /Users/stan/Desktop/projects/ably/demo-ios/Pods/ably/ably-ios/ARTRealtime.m:1068
#5  0x0000000104290174 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#6  0x000000010428fd35 in __CFRunLoopDoTimer ()
#7  0x0000000104251d3d in __CFRunLoopRun ()
#8  0x0000000104251366 in CFRunLoopRunSpecific ()
#9  0x0000000108c8da3e in GSEventRunModal ()
#10 0x0000000104bc78c0 in UIApplicationMain ()
#11 0x0000000103fde747 in main at /Users/stan/Desktop/projects/ably/demo-ios/demo-ios/AppDelegate.swift:12
#12 0x0000000106e4b145 in start ()
@mattheworiordan
Copy link
Member

@fealebenpae are you able to help with this? This is a blocker at present unfortunately.

@ricardopereira
Copy link
Contributor

First of all, the logger is broken. The ARTRest class and the ARTRealtime class use different ARTLog instances and when you assign your own logger and do logger.logLevel = ARTLogLevel.Verbose it will be ignored on the ARTRest instance. That is something I can fix easily.

So, the complete log is:

2015-09-26 12:39:39.417 MyAbly[68504:15606964] DEBUG: ARTAuth: setting up auth method Basic
2015-09-26 12:39:39.419 MyAbly[68504:15606964] DEBUG: ARTAuth: setting up auth method Token
2015-09-26 12:39:39.420 MyAbly[68504:15606964] DEBUG: ARTAuth: signed token request.
2015-09-26 12:39:39.420 MyAbly[68504:15606964] VERBOSE: ARTAUTH creating signed token request callback
2015-09-26 12:39:39.421 MyAbly[68504:15606964] Current action: ARTRealtimeConnecting
2015-09-26 12:39:39.422 MyAbly[68504:15606964] VERBOSE: Transition to ARTRealtimeConnecting requested
2015-09-26 12:39:39.428 MyAbly[68504:15606964] VERBOSE: ARTAuth authTokenForceReauth
2015-09-26 12:39:39.428 MyAbly[68504:15606964] DEBUG: ARTAuth has no token. Requesting one now
2015-09-26 12:39:39.429 MyAbly[68504:15606964] VERBOSE: ARTAUTH signed token request callback called
2015-09-26 12:39:39.430 MyAbly[68504:15606964] DEBUG: ARTAuth: query time is being used
2015-09-26 12:39:39.434 MyAbly[68504:15606964] WebSocket connect
2015-09-26 12:39:39.447 MyAbly[68504:15606964] State event: 1
2015-09-26 12:39:39.964 MyAbly[68504:15606964] VERBOSE: ARTRest Http response is 200
2015-09-26 12:39:39.965 MyAbly[68504:15606964] DEBUG: ARTAuth tokenRequest strCb got {
    capability = "";
    clientId = Bob;
    keyName = "6p6USg.CNwGdA";
    mac = "+ME3EIDDEkTw2DYtUK0W12ncTP9ll+tqVutaSMJNlz8=";
    nonce = 1439700409300924;
    timestamp = 1443267579937;
    ttl = 3600000;
}
2015-09-26 12:39:39.966 MyAbly[68504:15606964] DEBUG: ARTRest is requesting a fresh token
2015-09-26 12:39:39.966 MyAbly[68504:15606964] VERBOSE: ARTAuth can request token via key
2015-09-26 12:39:39.966 MyAbly[68504:15606964] VERBOSE: using auth basic
2015-09-26 12:39:40.839 MyAbly[68504:15606964] VERBOSE: ARTRest Http response is 201
2015-09-26 12:39:40.839 MyAbly[68504:15606964] VERBOSE: ARTRest token is {
    "token": "6p6USg.C4x797ixr69iCoXe665yG34xnn-QEhdfccpfRToKkIl1ekOAFtkDIfmCl7wSJ3HouCU_QonZdXvVJ2EQyHrBX9FXnh-cTVSXeZqreILRVKXw",
    "keyName": "6p6USg.CNwGdA",
    "issued": 1443267580424,
    "expires": 1443271180424,
    "capability": "{\"*\":[\"*\"]}",
    "clientId": "Bob"
}
2015-09-26 12:39:40.843 MyAbly[68504:15606964] SocketRocket: In debug mode.  Allowing connection to any root cert
2015-09-26 12:39:54.427 MyAbly[68504:15606964] WARN: ARTRealtime connecting timer fired.
2015-09-26 12:39:54.427 MyAbly[68504:15606964] Current action: ARTRealtimeFailed
2015-09-26 12:39:54.428 MyAbly[68504:15606964] VERBOSE: Transition to ARTRealtimeFailed requested
2015-09-26 12:39:54.431 MyAbly[68504:15606964] State event: 7

@mattheworiordan Do you see any suspicious?

@ricardopereira
Copy link
Contributor

Resolved with #31. Can be closed.

ricardopereira added a commit that referenced this issue Aug 22, 2019
 - This failed in RTP9a because it sometimes ends but the ACK/NACK of the last sent presence message has not arrived yet, it means the callback is pended. The callback is called when the connection closes (test ends), a "ARTErrorInfo with code 0, message: connection broken before receiving publishing acknowledgment." happens and it will crash because the callback is nil.

EXC_BAD_ACCESS (code=1, address=0x10) in ARTRealtimeChannel.m:335

Thread 3 Queue : io.ably.tests (serial)
#0	0x000000012186c6b4 in __47-[ARTRealtimeChannel publishPresence:callback:]_block_invoke.164 at /<redacted>/ably-cocoa/Source/ARTRealtimeChannel.m:335
#1	0x000000012186ecdd in __43-[ARTRealtimeChannel sendMessage:callback:]_block_invoke at /<redacted>/ably-cocoa/Source/ARTRealtimeChannel.m:450
#2	0x00000001218be38e in __22-[ARTEventEmitter on:]_block_invoke at /<redacted>/ably-cocoa/Source/ARTEventEmitter.m:209
#3	0x00000001083ff632 in -[__NSObserver _doit:] ()
#4	0x00000001094827bc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#5	0x0000000109481c3f in _CFXRegistrationPost ()
#6	0x0000000109481983 in ___CFXNotificationPost_block_invoke ()
#7	0x00000001095657c2 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#8	0x00000001094812d1 in _CFXNotificationPost ()
#9	0x00000001083ffddb in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#10	0x00000001218bf843 in -[ARTEventEmitter emit:with:] at /<redacted>/ably-cocoa/Source/ARTEventEmitter.m:275
#11	0x0000000121915222 in -[ARTRealtime transition:withErrorInfo:] at /<redacted>/ably-cocoa/Source/ARTRealtime.m:429
#12	0x0000000121914c0a in -[ARTRealtime transition:] at /<redacted>/ably-cocoa/Source/ARTRealtime.m:412
#13	0x000000012191b755 in -[ARTRealtime onClosed] at /<redacted>/ably-cocoa/Source/ARTRealtime.m:768
#14	0x0000000121928933 in -[ARTRealtime realtimeTransport:didReceiveMessage:] at /<redacted>/ably-cocoa/Source/ARTRealtime.m:1392
#15	0x00000001218c4bef in -[ARTWebSocketTransport receive:] at /<redacted>/ably-cocoa/Source/ARTWebSocketTransport.m:109
#16	0x00000001218c4cbe in -[ARTWebSocketTransport receiveWithData:] at /<redacted>/ably-cocoa/Source/ARTWebSocketTransport.m:114
#17	0x00000001218c7c44 in -[ARTWebSocketTransport webSocketMessageData:] at /<redacted>/ably-cocoa/Source/ARTWebSocketTransport.m:367
#18	0x00000001218c77a0 in -[ARTWebSocketTransport webSocket:didReceiveMessage:] at /<redacted>/ably-cocoa/Source/ARTWebSocketTransport.m:349
#19	0x0000000121bf06c9 in __43-[SRWebSocket _handleFrameWithData:opCode:]_block_invoke.239 ()
#20	0x000000010b3e2ccf in _dispatch_call_block_and_release ()
#21	0x000000010b3e3d02 in _dispatch_client_callout ()
#22	0x000000010b3ea720 in _dispatch_lane_serial_drain ()
#23	0x000000010b3eb261 in _dispatch_lane_invoke ()
#24	0x000000010b3f3fcb in _dispatch_workloop_worker_thread ()
#25	0x000000010bb12611 in _pthread_wqthread ()
#26	0x000000010bb123fd in start_wqthread ()
@tcard tcard mentioned this issue Dec 1, 2019
4 tasks
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

4 participants