triniwiz / nativescript-plugins

Apache License 2.0
78 stars 50 forks source link

Error when connecting to socket server on iOS only [@triniwiz/nativescript-socketio] #158

Open OPADA-Eng opened 1 year ago

OPADA-Eng commented 1 year ago

Hi I'm trying to use the plugin on iOS but it fails to connect to the socket server with error message:

error: error Invalid HTTP upgrade. code=308, type=upgradeError ns version:

{
"dependencies": {
    "@nativescript/core": "^8.4.1",
    "@triniwiz/nativescript-socketio": "^4.0.3",
},
 "devDependencies": {
        "@nativescript/android": "~8.4.0",
        "@nativescript/ios": "8.4.0",
        "@nativescript/types": "~8.4.0",
        "@nativescript/webpack": "~5.0.9",
        "typescript": "~4.8.3"
    }
}

My Code:

let options = {
                transports: ['websocket'],
                query: {
                    room: roomName,
                    token: 'XXX',
                },
                android: {

                },
                ios: {
                    log: true,
                }
            }
          DOService.MySocket = new SocketIO(domain, options);
          DOService.MySocket.connect();

          DOService.MySocket.on('connect', function () {
              DOService.socketConnected = true;
              console.log('connected', DOService.socketConnected);
          });

          DOService.MySocket.on('disconnect', function (data) {
              console.log('disconnect', data);
              DOService.socketConnected = false;
          });

          DOService.MySocket.on('error', function (error) {
              console.dir('error', error);
          });

Can Anybody help?