deepstreamIO / deepstream.io-client-ios

The iOS client for deepstream.io
Other
17 stars 15 forks source link

Can't connect DeepstreamHubURL with real domain #12

Closed minhdatplus closed 4 years ago

minhdatplus commented 7 years ago

I try to connect to Deepstream url with javascript client, Java client, ios client with localhost.All of them is the success.But when I log in with the real domain, all of them is a success except ios client (Swift). Please tell my why Deepstream doesn't return success or error when I connect.

akramhussein commented 7 years ago

Hi @Noviato can you clarify what you mean by real domain? Do you mean a domain to your own server?

minhdatplus commented 7 years ago

Hi @akramhussein , This domain "xxx.com" is my domain. I install deepstream on Ubuntu server, after that use Haproxy forwarding to server install deepstream but ios client can't connect. Thanks for help me.

func setupDeepstream() {
        let DeepstreamHubURL = "xxx.com/deepstream"

        IOSDeepstreamFactory.getInstance().getClient(DeepstreamHubURL, callback: { (client) in
            guard let c = client else {
                print("Unable to initialize client")
                return
            }
            self.client = c
            guard let loginResult = self.client?.login() else{
                print("Unable to get login result")
                return
            }

            if (loginResult.getErrorEvent() == nil) {
                print("Successfully logged in")
            } else {
                print("Error: Failed to log in...exiting")
                return
            }

            self.client?.event.subscribe("navito/realprice", eventListener: self)
        })
    }
forwarding port 6020
connectionEndpoints:
  webSocket:
    name: uws
    options:
        # port for the websocket server
        port: 6020
        # host for the websocket server
        host: 0.0.0.0
        # url path websocket connections connect to
        urlPath: /socket
        # url path for http health-checks, GET requests to this path will return 200 if deepstream is alive
        healthCheckPath: /health-check
        # the amount of milliseconds between each ping/heartbeat message
        heartbeatInterval: 30000
        # the amount of milliseconds that writes to sockets are buffered
        outgoingBufferTimeout: 0

        # Security
        # amount of time a connection can remain open while not being logged in
        unauthenticatedClientTimeout: 180000
        # invalid login attempts before the conne
```ction is cut
        maxAuthAttempts: 3
        # if true, the logs will contain the cleartext username / password of invalid login attempts
        logInvalidAuthData: false
        # maximum allowed size of an individual message in bytes
        maxMessageSize: 1048576
akramhussein commented 7 years ago

Hi @Noviato - your setup iOS code looks correct.

I'm wondering if HAProxy is doing a re-direct and for some reason it can't communicate back. @yasserf do you think this is perhaps is a re-direct issue? What would be the best way to test it?

Just to confirm, what version of Deepstream client on iOS are you using and what server version?

akramhussein commented 7 years ago

@Noviato also to check, are you running it on ws or wss

oancius commented 6 years ago

Hi @akramhussein i face the same problem, i try to connect from an ios-swift app to a wss that has no auth restrictions at this moment, i'm using Deeptream 2.0 pod because this seems to be auto installed by CocoaPods. I did the bridging header, also added it in project build settings, the problem is when you have to drag the Resources folder from pods/Deepstream to project xcode crashes 👎 but without this move no errors appear, the app gets built, but when you run it gets instant crash with this message:

*** Terminating app due to uncaught exception 'JavaLangRuntimeException', reason: 'java.lang.RuntimeException: java.security.NoSuchAlgorithmException: SSLContext TLS implementation not found'

Here it's the basic code that i use

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        guard let client = DeepstreamClient("wss://ds.xxxyyy.io") else {
            // failed to connect to setup a DeepstreamClient
            return
        }
        guard let loginResult = client.login() else {
            // failed to login
            return
        }

        if (loginResult.getErrorEvent() == nil) {
            print("Successfully logged in")
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}