triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Use with feathersVuex #83

Open bzd2000 opened 5 years ago

bzd2000 commented 5 years ago

Which platform(s) does your issue occur on?

Hi, I would like to use this plugin with feathersjs by use of th feathersVuex plugin. It is connecting to the feathers backend, but then I get the following error " TypeError: Cannot read property 'engine' of undefined"

and it is happening in this code of the @feathersjs/authentication-client (/lib/passport.js)

 const socketUpgradeHandler = () => {
      socket.io.engine.on('upgrade', () => {
        debug('Socket upgrading');

        // If socket was already authenticated then re-authenticate
        // it with the server automatically.
        if (socket.authenticated) {
          const data = {
            strategy: this.options.jwtStrategy,
            accessToken: app.get('accessToken')
          };

          this.authenticateSocket(data, socket, emit)
            .then(this.setJWT)
            .catch(error => {
              debug('Error re-authenticating after socket upgrade', error);
              socket.authenticated = false;
              app.emit('reauthentication-error', error);
            });
        }
      });
    };

    if (socket.io && socket.io.engine) {
      socketUpgradeHandler();
    } else {
      socket.on('connect', socketUpgradeHandler);
    }
  }

Somehow it doesn't find the engine property at socket.io.engine. Any idea how to fix this code to work with your plugin?