Привет. Я пытаюсь подключиться к работающему серверу, но не могу подключиться к работающему серверу. но работает нормально на localhost. Это мой код
class SocketIOManager: NSObject
{
var Delegate:SocketIOManagerDelegate?
var notificationmode : NSString = NSString()
static let sharedInstance = SocketIOManager()
var iSSocketDisconnected:Bool=Bool()
var iSChatSocketDisconnected:Bool=Bool()
var orderId:String = String()
static var constant_class:Constant=Constant()
static var theme:Themes=Themes()
var audioPlayer :AVAudioPlayer!
var nick_name:NSString=NSString()
let commonUtlity : Utilities = Utilities();
var Appdel=UIApplication.shared.delegate as! AppDelegate
let manager = SocketManager(socketURL: URL(string: constant_class.SocketCreateRoomUrl as String)!, config: [.log(true), .compress, .forcePolling(true), .reconnects(true), .reconnectAttempts(-1), .secure(false), .forceWebsockets(true)])
var socket:SocketIOClient!
override init()
{
socket = manager.defaultSocket
socket = manager.socket(forNamespace: "/chat")
super.init()
}
func establishConnection(Nickname:NSString)
{
if(socket != nil)
{
if(socket.status == .disconnected || socket.status == .notConnected)
{
socket.removeAllHandlers()
addListeners(Nickname:Nickname)
socket.connect()
}
}
}
func addListeners(Nickname:NSString) {
ListensocketEvents(Nickname:Nickname)
ListenUserCreated()
Litentochat(Nickname:Nickname)
}
Это мои журналы
2020-01-08 09:01:33.719888+0100 DeliveryDom Driver[2386:686588] LOG SocketManager: Trying to reconnect
2020-01-08 09:01:33.720393+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/}: Handling event: reconnectAttempt with data: [-7]
2020-01-08 09:01:33.720664+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/chat}: Handling event: reconnectAttempt with data: [-7]
2020-01-08 09:01:33.721133+0100 DeliveryDom Driver[2386:686588] LOG SocketManager: Scheduling reconnect in 30.0s
2020-01-08 09:01:33.721579+0100 DeliveryDom Driver[2386:688440] LOG SocketEngine: Starting engine. Server: ws://deliverydom.pl
2020-01-08 09:01:33.721881+0100 DeliveryDom Driver[2386:688440] LOG SocketEngine: Handshaking
2020-01-08 09:01:34.593543+0100 DeliveryDom Driver[2386:688440] ERROR SocketEngine: Invalid HTTP upgrade. code=400, type=upgradeError
2020-01-08 09:01:34.593589+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/}: Handling event: websocketUpgrade with data: [["access-control-allow-origin": "ws", "server": "Apache/2.4.18 (Ubuntu)", "x-cache": "MISS from localhost", "date": "Wed, 08 Jan 2020 08", "connection": "keep-alive", "access-control-allow-credentials": "true", "transfer-encoding": "chunked", "content-type": "application/json"]]
2020-01-08 09:01:34.594140+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/chat}: Handling event: websocketUpgrade with data: [["access-control-allow-origin": "ws", "server": "Apache/2.4.18 (Ubuntu)", "x-cache": "MISS from localhost", "date": "Wed, 08 Jan 2020 08", "connection": "keep-alive", "access-control-allow-credentials": "true", "transfer-encoding": "chunked", "content-type": "application/json"]]
2020-01-08 09:01:34.594586+0100 DeliveryDom Driver[2386:686588] ERROR SocketManager: Invalid HTTP upgrade. code=400, type=upgradeError
2020-01-08 09:01:34.594850+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/}: Handling event: error with data: ["Invalid HTTP upgrade. code=400, type=upgradeError"]
2020-01-08 09:01:34.595108+0100 DeliveryDom Driver[2386:686588] LOG SocketIOClient{/chat}: Handling event: error with data: ["Invalid HTTP upgrade. code=400, type=upgradeError"]
Я также упоминал в info.Plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Работает нормально в android I также проверить мобильные данные. Я также проверяю как «ws: //liveurl.com/» или «http://liveurl.com/»