askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.94k forks source link

Gekko Install Instructions Almost Work, but "Disconnected" AFTER UI is Successfully Served #2004

Closed jdhadwin closed 6 years ago

jdhadwin commented 6 years ago

Note: for support questions, please join our Discord server

const CONFIG = { headless: true, //false api: { host: '127.0.0.1', port: 3000 //timeout: 120000 // 2 minutes }, ui: { ssl: true, //false, host: '159.89.85.80', port: 443, path: '/' }, adapter: 'sqlite' }

if(typeof window === 'undefined') module.exports = CONFIG; else window.CONFIG = CONFIG;

10) ran apt-get update and apt-get upgrade one more time just for kicks, then rebooted the server and logged back in via ssh 11) fired up Gekko by typing node ~/gekko/gekko --ui. (everything looks normal in the Terminal window at this point) 11a) opened Mac's Safari browser and navigated to my server's IP address, clicked through the annoying self-signed certificate warnings and came to htpassword login 11b) Login via htpassword is successful, UI page is served in the browser, and everything looks good in the terminal too 11c) The UI page loaded in the browser immediately produces a "Disconnected" message in a modal lightbox, which says, "Disconnected Something happened to either Gekko or the connection. Please check the terminal where Gekko is running or your network connection." 11d) The server terminal window shows nothing but 200s. 11e) The web browser console shows repetitive errors of "WebSocket connection to 'wss://159.89.85.80/api/' failed: Unexpected response code: 401" 11f) The web browser console shows a log which says "You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html" 12) Repeated stop 11a-c in alternate web browsers, including Firefox, Chrome, and Brave, with the same results in the browser, but different results from the Terminal window, as follows. 12a) /api/404 1ms - 12b) Web browser's console says "reconnecting-websocket.min.js:2 WebSocket connection to 'wss://159.89.85.80/api/' failed: Error during WebSocket handshake: Unexpected response code: 404"

Unfortunately, #1528 other articles with similar problems were not able to help me resolve my problem, including #934

Posted problem in Discord #help-1 channel... without successful resolution... however I did manage to pick up a brute force attack on my htpassword while I was in there posting screenshots that contained my IP address, lol. In keeping with that spirit, I'll keep the IP address going for this posting too. It should only take about half a millennium or two to brute-force their way into my UI and enjoy the spoils of my zero balance and non-existent exchange API keys.

I've provided screenshots as visual references for various steps listed above.

(see #11b) screen shot 2018-03-06 at 12 20 46 pm

(see #11c-f) screen shot 2018-03-06 at 12 22 25 pm

(see #12) screen shot 2018-03-06 at 12 24 25 pm

Thanks for the help. Looking forward to getting gekko going.

jellicoe commented 6 years ago

in

~/gekko/web/vue/UIconfig.js

where you have host: '127.0.0.1',

should be

host: '0.0.0.0',

jdhadwin commented 6 years ago

Thank you jellicoe...

The installation guide says to use 127.0.0.1 for Configuring Gekko to Run in the Cloud

https://gekko.wizb.it/docs/installation/installing_gekko_on_a_server.html#Configuring-Gekko-to-run-in-the-cloud

Nevertheless, I tried it, and 0.0.0.0 doesn't render any different results... I got the exact same results.

janushansen commented 6 years ago

Hi All

I face the exact same issue !

Try to get my pi to host the gekko and I like the dhcp option for my pi; so is there a way to define the host without using the specific ip ?

skaermbillede 2018-03-08 kl 20 23 23

skaermbillede 2018-03-08 kl 20 20 01 skaermbillede 2018-03-08 kl 20 20 20

UPDATE: Found the static way to get my GEKKO up running ! But still, if there is a dynamic way.. please let me know , Thx :)

Below the fix:

const CONFIG = { headless: false, api: { host: '10.170.0.159', port: 3000, timeout: 120000 // 2 minutes }, ui: { ssl: false, host: '10.170.0.159', port: 3000, path: '/' }, adapter: 'sqlite' }

jdhadwin commented 6 years ago

I can gain access to gekko via an unsecured workaround, by changing step 9b as follows

const CONFIG = { // headless: true, api: { host: '159.89.85.80, port: 3000 }, ui: { //ssl: true, host: '159.89.85.80', port: 3000, path: '/' // change this if you are serving from$ }, adapter: 'sqlite' }

and thereby bypassing the security by visiting http://159.89.85.80:3000 (with no htpassword or ssl) instead of https://159.89.85.80 (with htpassword and ssl), which is obviously an unacceptable workaround, but I thought it'd be useful to post here the results of my experimentation here.

I can't figure this one out... please help :)

askmike commented 6 years ago

@jdhadwin @janushansen if you see the message:

"Disconnected - Something happened" to either Gekko or the connection" that means the following:

Your browser WAS able to talk directly to Gekko (which is why you see the UI in the background) however your browser WAS NOT able to set up a websocket connection with the gekko process. If you are running Gekko in the cloud and you use reverse proxy (like nginx) this means one of the following:

How to troubleshoot

  1. check the server logs for errors.
  2. check the browsers developer tools for connection errors.

Based on these errors you can fix it. I'll try to write a guide here soon to go into the kind of errors and what they mean.

jdhadwin commented 6 years ago

@askmike Hey mike, thanks a million for helping with this.

Using a normal internet connection not 3g. I'm also keeping my ssh session alive throughout these tests, so those aren't the problem. Running nginx 1.12.1, which fully supports websockets

My server log has no relevant problems :/

After doing a lot of learning about nginx, websockets, and so on, I tried lots of things that didn't work, and then I found this comment by netcoding at https://github.com/askmike/gekko/issues/967#issuecomment-367980686 which sent me on a rabbit trail with my sshd_config. After seeing there was no solution there, I put everything back the way it was and fired up gekko... I again checked in safari browser and found the websocket to be disconnected still... but this time, firefox and chrome were working perfectly! Yes, that's right, gekko is working.

I think that I must have had some stray characters floating around my nginx config file that were causing the problem... and at some point I must have written over them (fixing the problem) and since I wasn't constantly checking firefox and chrome but was mainly testing in safari I didn't notice, and still don't know what happened... but what (and still is) going on with gekko on safari? I only have a theory. I think that safari is not capable of dealing with self-signed wss calls, thus the 401.

So, for now (for me), case closed :)

xbromy commented 6 years ago

I just did an upgrade to current develop branch from a version 2 month back and I'm now also facing this issue. Do I need to change something in nginx settings? So it says Gekko Version 0.6.0 and UI 0.2.2 is that the current release? I fetched the v0.6.1 tag

I don't know but after quit from ssh it's working now...