ERROR SocketEnginePolling: Error during long poll request
Asked Answered
E

3

11
let manager = SocketManager(socketURL: URL(string: "Some url")!, config: [.log(true), .compress])
var socket:SocketIOClient!
var name: String?
var resetAck: SocketAckEmitter?



override func viewDidLoad() {
    super.viewDidLoad()
    
    socket = manager.defaultSocket

    socket.on(clientEvent: .connect) {data, ack in
        print("socket connected")
    }

    self.socket.on(clientEvent: .error) {data, ack in
        print("error")
    }

    self.socket?.on(clientEvent: .disconnect){data, ack in

        print("disconnect")

    }

    socket.connect()
    
    
}

ERROR SocketEnginePolling: Error during long poll request

LOG SocketIOClient{/}: Handling event: error with data: ["Error"]

Epistemic answered 24/6, 2020 at 18:4 Comment(1)
Check your server logs and when the swift-client connects look for a message, "The client is using an unsupported version of the Socket.IO or Engine.IO protocols". If you see this message, update Socket.io-Swift-Client to the latest version. This fixed the issue for me.Worthen
O
8

update pod to Socket.IO-Client-Swift 16.0.1

Ovular answered 11/1, 2022 at 13:33 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Trevelyan
@Eman Gaber its work for me thanksAnnikaanniken
G
3

So this problem gave me quite an agonizing 8-hour of digging and here are the steps I followed to solve the problem.

  1. Check if you are using 'localhost:PORTNUMBER' as your URL. Instead, try using temporary 'https' using ngrok ngrok.

  2. If you insist on using http, try disabling App Transport Security policy in your project's info.plist

  3. Check if you are using a compatible Client(iOS) and Server(Node js, and etc) Socket.io version. You can check compatibility table here.

    • A simple fix is to drop server Socket.io version to 1.x.x.
    • to keep server Socket.io version to 4.x.x (current at the time of this writing) add allowEI03: true option when instantiating the server:
      const io = new Server(httpServer, {
        allowEIO3: true
      });
    
    • If you are making a server using express I suggest this:
      const express = require("app");
      const { createServer } = require("http");
      const { Server } = require("socket.io");
      const app = express();
      const httpServer = createServer(app);
    
      const io = new Server(httpServer, { 
        allowEIO3: true,
      });
    
      io.on("connection", (socket) => {
        // ...
      });
    
      httpServer.listen(3000);
    
Galeiform answered 10/10, 2021 at 15:28 Comment(1)
Is the latest version of swift 16 and why is it 15 on github?Pentimento
C
0

upgrade your package version to 16.0.1. This worked for me too!!!

Cultrate answered 9/9, 2022 at 7:35 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Evora

© 2022 - 2024 — McMap. All rights reserved.