Dear Team,
I am using webview(WKWebview), in which I am trying to make Websocket with server. I have created WebSockets using URLSessionWebSocketTask. when I connect the Websocket to any port under my Webview host, it works:
if my webview url is: 192.168.1.55:8090 and websocket url is : 192.168.1.55:8099, it works and connects ( I tested with using custom Nodejs Sever running on 192.168.1.55:8099)
But if my webview url is: 192.168.1.55:8090 and websocket url is : 192.168.1.110:8099, it never connects.
Why is this problem happening ?
I added in info.plist: NSAllowsArbitraryLoads key to YES under NSAppTransportSecurity , but it still doesn't work.
urlKommSession = URLSession(configuration: .default, delegate: self, delegateQueue: nil)
guard let url = URL(string: urlStr) else { print("url problem")
return }
if (url != nil) {
self.webSocketTaskKomm = try urlKommSession?.webSocketTask(with: url)
self.webSocketTaskKomm.resume()
}
I am receiving connection Status in:
func urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didOpenWithProtocol protocol: String?) {
print("Connection Opened")
}