ios – PusherSwift Can’t establish a websocket connection


I’m trying to connect to a socket from my own application, when I call pusher.connect() the following is displayed in the console:

2024-01-23 13:05:30.963189+0500 pusher_test[64299:2525981] [] nw_protocol_copy_ws_definition_block_invoke [C1:1] nw_ws_validate_server_response
2024-01-23 13:05:30.964076+0500 pusher_test[64299:2525981] [connection] nw_read_request_report [C1] Receive failed with error "Software caused connection abort"

enter image description here

Below is my code for testing

        class AuthRequestBuilder: AuthRequestBuilderProtocol {
            func requestFor(socketID: String, channelName: String) -> URLRequest? {
                var request = URLRequest(url: URL(string: authPath)!)
                request.httpMethod = "POST"
                request.addValue("Bearer "+token, forHTTPHeaderField: "Authorization")
                request.addValue("application/json", forHTTPHeaderField: "Content-Type")
                request.addValue("application/json", forHTTPHeaderField: "Accept")
                return request

            }
        }

        let optionsWithEndpoint = PusherClientOptions(
            authMethod: AuthMethod.authRequestBuilder(authRequestBuilder: AuthRequestBuilder()),
            host:.host(host),
            port:6001,
            useTLS: false
        )
        pusher = Pusher(key: "pusher_app_key", options: optionsWithEndpoint)
        
        pusher.connect()
        
        let myPresenceChannel = pusher.subscribeToPresenceChannel(channelName: "presence-online")
        

I write in flutter and am new to swift, but the error occurs in native, that’s why I’m here.
xcode version: 14.3.1.
Swift version: swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
I tested it on the iOS simulator, but the error persists on a real device

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img