Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble authenticating user #100

Open
david-harkey opened this issue Oct 12, 2017 · 2 comments
Open

Trouble authenticating user #100

david-harkey opened this issue Oct 12, 2017 · 2 comments

Comments

@david-harkey
Copy link

david-harkey commented Oct 12, 2017

I am having trouble authenticating my app's node user. Here is my setup:

  1. I am running murmur, an instance of the normal mumble client, and an instance of an nw.js app running this codebase, all on the same computer.
  2. I can see the app's user showing up on the normal client's screen after client.authenticate( userName ); is called.
  3. Channel/User data is received by the app and printed fine to the console, but the 'initialize' callback never fires.
  4. I generated the certificate via command line, and can confirm that the key/cert option attributes are saving correctly in the app.
  5. In the murmur log, I'm getting the following message every time the app tries to connect:
    <W>2017-10-12 09:44:06.022 1 => <70:(-1)> New connection: 127.0.0.1:49475
    <W>2017-10-12 09:44:06.022 Connection: Failed to add flow to QOS
    <W>2017-10-12 09:44:06.077 1 => <70:TestUserName(-1)> Authenticated
    ...That middle line seems to be a clue. That last line seems to indicate that the app/node user is authenticated, but I still don't see the 'authenticate' event firing in the app (via callback statements).

Any thoughts?

------------Edit--------------

  1. Re: 5) above, I don't think that QOS message is an issue. I get that when my normal mumble client runs on my computer, and it connects and has full functionality. (When I connect over a network from another device, I don't get it, meaning that this is likely an end-to-end encryption check that will fail when the client and server are on the same machine.)

  2. The real issue seems to be the the 'initialize' callback never firing. That is what I'm trying to ultimately gain access to so I can start customizing the functionality for my app. I seem to be authenticating fine, otherwise the server wouldn't send back the channel/user states. Just looking for that pesky callback to fire!

Thank you in advance for any help you can provide.

@david-harkey
Copy link
Author

david-harkey commented Oct 12, 2017

Here's my index.js:

var mumble = require('mumble');
var fs = require('fs');
var path = require('path');

const userName = "TestUserName";
const server_IP = "localhost";

// node-mumble variables
var connectOptions = {
    key: fs.readFileSync( 'app/license/key.pem' ),
    cert: fs.readFileSync( 'app/license/cert.pem' )
};
var sessions = {};
var channels = {};

console.log( 'Connecting' );
// mumble.connect( 'mumble://'+userName+'@'+server_IP, connectOptions, function ( error, client ) {
mumble.connect( 'mumble://'+server_IP, connectOptions, function ( error, client ) {
    if( error ) { throw new Error( error ); }

    console.log( 'Connected' );

    //////////////////////EVENT HANDLERS//////////////////////
    //starts authentication handshake
    client.authenticate( userName );
    //fire off once authentication is complete
    // connection.on( 'initialized', onInit );
    client.on( 'initialized', function() {
        console.log( 'Client authenticated' );
        // Connection is authenticated and usable.
    });

    //lib/Channel.js emitted events
    client.on( 'channelState', onChannelState );
    client.on( 'textMessage', onTextMessage );
    client.on( 'userState', onUserState );

    //MumbleConnection.js emitted events
    client.on( 'protocol-in', onProtocolIn );
    client.on( 'reject', onReject);
    client.on( 'ready', onReady);
    client.on( 'error', onError);
    client.on( 'user-update', onUserUpdate);
    client.on( 'voice-start', onVoiceStart);
    client.on( 'voice-end', onVoiceEnd);
    client.on( 'voice-frame', onVoiceFrame);
    client.on( 'voice', onVoice );

});

var onVoice = function( voice ) {
    console.log( 'Mixed voice', voice );
    var pcmData = voice;
};

var onProtocolIn = function( data ) {
  // Show all incoming events and the name of the event which is fired.
  console.log('ProtocolIn', data.handler, 'data', data.message);
};

var onUserState = function( state ) {
  console.log( 'User State', state );
  console.log( connection.userBySession( state.session ) );
  // Collect user information
  sessions[state.session] = state;
};

var onChannelState = function( state ) {
  console.log( 'Channel State', state );
  // Collect channel information
  channels[state.channelId] = state;
};

var onTextMessage = function( data ) {
  console.log( 'Text Message', data );
  // On text message...
  var user = sessions[data.actor];
  console.log(user.name + ':', data.message);
};

var onVoice = function( event ) {
  // On voice...
  console.log( 'Mixed voice', event );
  var pcmData = event.data;
};

// fires constantly, but frame.length is always 0, even when talking
var onVoiceFrame = function( frames ) {

  if(frames.length != 0){
    console.log( 'VoiceFrame', frames );
  }

    // COMMENTED OUT BECAUSE IT FIRES CONSTANTLY
    // connection.authenticate( 'spy' );
    // for( var f in frames ) {
    //     console.log( frames[ f ].user ? frames[ f ].user.name : '<no-user>' );
    // }
}

var onReady = function( event ) {
  // On voice start...
  console.log( 'Ready', event );
  var pcmData = event.data;
};

var onVoiceStart = function( event ) {
  // On voice start...
  console.log( 'Voice Started', event );
  var pcmData = event.data;
};

var onVoiceEnd = function( event ) {
  // On voice end...
  console.log( 'Voice Ended', event );
  var pcmData = event.data;
};

var onError = function( event ) {
  // On voice end...
  console.log( 'Error', event );
  var pcmData = event.data;
};

var onAuthenticateOut = function( event ) {
  // On authentication message sent...
  console.log( 'Authenticating (out)', event );
  //var pcmData = event.data;
};

var onReject = function( event ) {
  // On authentication message sent...
  console.log( 'Reject', event );
  //var pcmData = event.data;
};

@david-harkey
Copy link
Author

Fixed it! The line
console.log( connection.userBySession( state.session ) );
was causing the code to seize up without error. Commenting this line out made the nw.js app run as expected.

I'm not sure if this only affects nw.js developers or not. Maybe worth putting a note in the code about it? I dunno.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant