sematext / logsene-cli

Logsene Command-line Interface
http://sematext.com/logsene
Apache License 2.0
10 stars 5 forks source link

SSL & proxy issues #2

Closed auselen closed 9 years ago

auselen commented 9 years ago

I think I am not able to use logsene-cli because of the corporate proxy.

$ logsene config set --app-key 1111-2222-333-444-555
No active sessions. Please log in using your Sematext account:
Enter your username: xxx
Enter your password: 
◓/usr/local/lib/node_modules/logsene-cli/lib/logsene-api.js:68
    out.trace('Login error.\n' + err.data.toString());  // materialize buf
                                         ^
TypeError: Cannot read property 'toString' of undefined
    at Request.fn [as _callback] (/usr/local/lib/node_modules/logsene-cli/lib/logsene-api.js:68:46)
    at self.callback (/usr/local/lib/node_modules/logsene-cli/node_modules/request/request.js:198:22)
    at Request.emit (events.js:107:17)
    at Request.onRequestError (/usr/local/lib/node_modules/logsene-cli/node_modules/request/request.js:867:8)
    at ClientRequest.emit (events.js:107:17)
    at ClientRequest.onError (/usr/local/lib/node_modules/logsene-cli/node_modules/tunnel-agent/index.js:176:21)
    at ClientRequest.g (events.js:199:16)
    at ClientRequest.emit (events.js:107:17)
    at TLSSocket.socketErrorListener (_http_client.js:271:9)
    at TLSSocket.emit (events.js:129:20)
    at onwriteError (_stream_writable.js:317:10)
    at onwrite (_stream_writable.js:335:5)
    at WritableState.onwrite (_stream_writable.js:105:5)
    at fireErrorCallbacks (net.js:456:13)
    at TLSSocket.Socket._destroy (net.js:495:3)
    at WriteWrap.afterWrite (net.js:777:10)

If I skip undefined print I get something like

Login was not successful{"jse_shortmsg":"Error while logging in.","jse_summary":"Error while logging in.: tunneling socket could not be established, cause=write EPROTO 140176374314816:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:782:\n","jse_cause":{"code":"ECONNRESET"},"message":"Error while logging in.: tunneling socket could not be established, cause=write EPROTO 140176374314816:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:782:\n"}
Unable to login: Login was not successful. Possibly wrong username or password.
otisg commented 9 years ago

@auselen Can you try using --api-key (not --app-key)? Does that solve the problem?

auselen commented 9 years ago

I tried a few combinations and none did work. However I tried it from a non-proxy network and it was ok. So I don't think I got the arguments wrong.

mbonaci commented 9 years ago

Hi @auselen, thanks for reporting. I'm looking into it and will report back the findings.

mbonaci commented 9 years ago

Hi @auselen, could you try setting environment variable HTTPS_PROXY and then try to use the logsene command. You should set it to URL of your company's https proxy server, e.g.

HTTPS_PROXY=https://your-ssl-proxy.com

The other thing I wanted to mention is that we don't use --app-key for a while now. We did use it a while back, but it was since renamed to more intuitive --token (and more distinctive when compared to --api-key). So just make sure you're using the latest logsene-cli version, 1.3.1, like this:

npm list -g --depth=0

If it's not 1.3.1, you can then do:

npm update logsene-cli -g

And BTW, you don't need to set --token explicitly, just use logsene search and you'll get prompted to log in and then to choose the Logsene app you want to work with, which will pull down your --api-key and --token behind the scenes, and store it in your local logsene-cli session store.

Thanks

megastef commented 9 years ago

Hi, I just like to add that we use the "request" npm module and support the environment variables

in the following projects:

auselen commented 9 years ago

Thanks! request npm module hint helped. It looks like I had to set https_proxy to "http://" instead of "https://".

mbonaci commented 9 years ago

Great @auselen, thanks for the feedback :+1: And thank you @megastef for the hint. I'm starting to think you should be @gigasteph :)