browsermob-node icon indicating copy to clipboard operation
browsermob-node copied to clipboard

Callback for Example Script never executes

Open tlhunter opened this issue 8 years ago • 2 comments

Script:

var Proxy = require('browsermob-proxy').Proxy             
  , proxy = new Proxy()                                   
  , fs = require('fs');                                   
                                                          
console.log(' app running');                              
                                                          
proxy.doHAR('http://yahoo.com', function(err, data) {     
    console.log('callback running');                      
    if (err) {                                            
        console.error('ERROR: ' + err);                   
    } else {                                              
      console.log('happy', data);                         
        fs.writeFileSync('yahoo.com.har', data, 'utf8');  
    }                                                     
});                                                       

Output:

$ node index.js     
 app running      
$                  

browsermob-proxy v2.1.4 is running and logs output when the script runs

[INFO  2017-02-22T11:27:48,264 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Starting proxy at address: 0.0.0.0/0.0.0.0:8086                                                                                                                              
[INFO  2017-02-22T11:27:48,265 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Proxy listening with TCP transport   
[INFO  2017-02-22T11:27:48,266 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Proxy started at address: /0:0:0:0:0:0:0:0:8086                                                                                                                                                                                                                                                       

tlhunter avatar Feb 22 '17 19:02 tlhunter

this setup assumes the selenium server is running locally on port 4444 - is it?

zzo avatar Feb 23 '17 18:02 zzo

I had to update browsermob-proxy/index.js#selFunc to add a .call(cb) because end() does not accept a callback anymore, which blocks doHAR from returning the data. @zzo @tlhunter

jfkhoury avatar Mar 14 '17 17:03 jfkhoury