onConnect is not being called
waleedmahmood opened this issue · comments
Hi,
I have a this simple connection function
`func initializeActionCabel()
{
self.client = ActionCableClient(url: URL(string: "ws://ip.of.my.server:3000.tld/cable")!)
self.client.willConnect = {
print("Will Connect")
}
self.client.onConnected = {
print("Action Cable Connected!")
self.channel = self.client.create("ChatChannel")
}
self.client.onDisconnected = {(error: ConnectionError?) in
print("Action Cable Disconnected! \(error.debugDescription)")
}
self.client.onRejected = {
print("Action Cable Connection Rejected!")
}
self.client.willReconnect = {
print("Reconnecting to \(self.client.url)")
return true
}
self.client.onPing = {
print("On Ping")
}
self.channel?.onSubscribed = {
print("Subscribed to 'ChatChannel'")
}
self.channel?.onReceive = {(data: Any?, error: Error?) in
print("On Receive")
if let _ = error {
print(error)
return
}
}
// Connect!
self.client.connect()
}`
Problem is: willReconnect and onDisconnected are being called just fine. But onConnected callback is not called ever.
Can you please comment or see if i'm missing something? Thanks in advance.
Cheers.
We are having a similar issue - is there any resolution?
In my case there was some thing wrong on our server side setup. What i did was to connect to a public url as follows:
ws://actioncable-echo.herokuapp.com/cable
This actually made sure that, everything was working on Client side.