tidwall / SwiftWebSocket

Fast Websockets in Swift for iOS and OSX
MIT License
1.53k stars 247 forks source link

Unable to connect to websocketServer on esp8266 #117

Closed chadham closed 6 years ago

chadham commented 6 years ago

Am able to create a web socket to wss://echo.websocket.org and receive a reply but when I try connecting to a local esp8266 socket server with the following call, it doesn't work

    let socket = WebSocket("wss://10.0.1.83:80")
    print("Socket = \(socket)")
    socket.open()
    socket.send("Test")
    socket.event.open = {
        print("Socket Opened")
    }
    socket.event.close = { code, reason, clean in
        print("Socket closed")
    }
    socket.event.error = { error in
        print("Socket Error \(error)")
    }
    socket.event.message = { message in
        print("Socket message \(message)")
        if let text = message as? String {
            self.handleMessage(jsonString: text)
        }
    }
    print("Done")

OUTPUT is Socket = <SwiftWebSocket.WebSocket: 0x1c003de80> Done

Also set the delegate and added functions for open, close and error but they don't fire either

When I stop the app, the esp8266 reports a web socket was disconnects, but I never shows one was connected in the first place.

chadham commented 6 years ago

Apparently the esp library doesn't support wss, works with ws.