websockets: Connection has no connected path


I tried to connect to a esp32 room 32 using sockets. but when trying to connect to the micro-prozessor which works as the server the client (coded in swift) says:


Code Block
2021-03-20 15:34:55.157403+0100 connectionPlayground[2083:81450] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected"
2021-03-20 15:34:55.157543+0100 connectionPlayground[2083:81450] [connection] nw_socket_get_input_frames [C1:2] recvmsg(fd 11, 1024 bytes) [54: Connection reset by peer]
2021-03-20 15:34:55.158086+0100 connectionPlayground[2083:81450] Connection 1: received failure notification
2021-03-20 15:34:55.158410+0100 connectionPlayground[2083:81450] [connection] nw_connection_copy_connected_local_endpoint [C1] Connection has no connected path
2021-03-20 15:34:55.158456+0100 connectionPlayground[2083:81450] [connection] nw_connection_copy_connected_remote_endpoint [C1] Connection has no connected path
failure:Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" UserInfo={NSErrorFailingURLStringKey=http://172.20.10.2/, NSErrorFailingURLKey=http://172.20.10.2/}

I also changed the info.plist file and added this:


Code Block
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>172.20.10.2</key>
<dict>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</plist>


my current program looks like this:


Code Block  @IBAction func start(_ sender: Any) {
        
       
        print("start");
        let session = URLSession(configuration: .default, delegate: self, delegateQueue: OperationQueue())
        let url = URL(string: "ws://172.20.10.2/")!
        let webSocketTask = session.webSocketTask(with: url)
        webSocketTask.receive { (result) in
            print("result")
            switch result{
            case .success(let message):
                switch message {
                case .string(let text):
                    print(text)
                default:
                    break
                }
            case .failure(let error):
                print("failure:\(error)")
                break
            default:
               break
            }
        }
        webSocketTask.resume()
    }









Answered by Systems Engineer in 667782022

Connection reset by peer

This is the part that I would debug first. This indicates that your connection could not connect to the peer, or the peer is shutting it down.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Accepted Answer

Connection reset by peer

This is the part that I would debug first. This indicates that your connection could not connect to the peer, or the peer is shutting it down.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
websockets: Connection has no connected path
 
 
Q