https://hyperstack.org has a built in hotloader that sets up a push notification from a task running on server, to the client.
I cant get this to work on gitpod.
after a minute or so the client throws this error:
WebSocket connection to 'wss://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io:25222/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
Here is my .gitpod.yml file:
tasks:
- init:
bundle install
- command:
bundle exec rake db:create &&
bundle exec rake db:migrate
ports:
- port: 5000
- port: 3000
- port: 9514
- port: 9515
- port: 25222
Any help is appreciated. The repo is here:
https://github.com/hyperstack-org/todo-compare use the `gitpodbranch
for simplicity I am running in two terminal windows instead of using foreman
terminal 1: bundle exec rails s -b 0.0.0.0 -p 5000
terminal 2:bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack/`
if you change a file in the app/hyperstack directoy you will see it is noticed but no message goes to the client.
The funny thing this safe app uses Rails action-cable, and that works fine!
Hi @catmando ,
on first sight your websocket URL looks bogus:
wss://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io:25222.
I'll have a look at https://gitpod.io/#https://github.com/hyperstack-org/todo-compare/tree/gitpod
that is just url that the page is pointing to with a different port.
in otherwords: https://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io
is the page I have loaded?
what would you expect it too look like?
FYI just double checked and works fine on my local box... i.e. I load page localhost:5000 and the hot-loader is running at wss://localhost:25222
The issues here is that hyperstack-hotloader assumes that the workspaces port 25222 is available at wss://<domain>:25222, while it actually is available at wss://25222-<workspace>:443.
I did not figure out how configure this in the hotloader, yet..
Btw, you can configure init and command to run in the same terminal like this (not tested)
tasks:
- init:
bundle install &&
yarn &&
bundle exec rake db:reset
command: bundle exec rails s -b 0.0.0.0 -p 5000
- init:
bundle exec rake db:create &&
bundle exec rake db:migrate
command: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack/`
for instance
thanks I'll figure it out... probably have to patch hotloader, but I can do that.
Yes, looks like that would be necessary. Currently Gitpod does not support incoming traffic on other ports than 443 - thought that might change in the future. :slightly_smiling_face:
The URL to insert there can be generated using gp url [port] like so:
gitpod /workspace/todo-compare $ gp url 25222
https://25222-f7b4807a-5ef0-458c-ac16-779595221da7.ws-eu0.gitpod.io/
thanks for the help...
I can get the hot-loader to work, but after about 90 seconds it closes the connection. Not sure why.
Again everything is posted here: https://github.com/hyperstack-org/todo-compare/tree/gitpod
and the hotloader "patch" is in app/hyperstack/components/hyper_component.rb
okay I starting pinging the websocket connection (server to client) every 10 seconds. That seems to keep it alive.
The only small thing is that when I run the hotloader using a foreman proc file after the initial hotloader message, non of the remaining messages come up.
gitpod /workspace/todo-compare $ bundle exec foreman start
19:03:35 web.1 | started with pid 10318
19:03:35 hot.1 | started with pid 10319
19:03:38 web.1 | => Booting Puma
19:03:38 web.1 | => Rails 5.1.6.2 application starting in development
19:03:38 web.1 | => Run `rails server -h` for more startup options
19:03:42 web.1 | Puma starting in single mode...
19:03:42 web.1 | * Version 3.12.0 (ruby 2.6.0-p0), codename: Llamas in Pajamas
19:03:42 web.1 | * Min threads: 5, max threads: 5
19:03:42 web.1 | * Environment: development
19:03:42 web.1 | * Listening on tcp://0.0.0.0:5000
19:03:42 web.1 | Use Ctrl-C to stop
19:04:57 web.1 | Started GET "/" for 127.0.0.1 at 2019-04-08 19:04:57 +0000
after the initial hot loader message (once puma starts?) no more hot messages come up.
Then later when you ctrl-c they all come flooding out.
I tried your example https://github.com/hyperstack-org/todo-compare/tree/gitpod and I see two websocket connection:

25222-...: the client sends empty frames to the server every few seconds, but never gets a response5000-...:/cable: There are two types of messages: ActionCable messages which get responses, and raw "pings" from the server, which don't get responses.I never did ruby but will try to play around a bit.
It seems to be an issue with foreman, really. I left it out and just started two terminals and it worked nicely with your changes:

I created a PR against your branch: https://github.com/hyperstack-org/todo-compare/pull/1
I noticed that the initial install takes some time: Gitpod has a GitHub-App that allows to "prebuild" workspaces (docs). This basically checks out your repo on each push and executes the init tasks in your .gitpod.yml. Whenever you create a workspace on that commit, you'll get a prebuilt version: all dependencies installed and generated. This service is free for public repositories.
Yes I configured hot loader to ping every 10 seconds. This seems to keep the connection alive.
The prebuild looks great can't wait to to try it.
And the pre-build works great. Thanks for the tip!
how i can install rails on gitpod? i am lost
Hi @guilhermeariza, to install Rails in Gitpod, it should be enough to just run gem install rails in the Terminal.
Most helpful comment
And the pre-build works great. Thanks for the tip!