Jump to content

Recommended Posts

Posted

I am trying to run a Ruby on Rails application that uses websockets via ActionCable.  On my local machine (which I used for testing it out) the code itself works fine, but when I uploaded it to Heliohost, the websockets part doesn't seem to be working.  I get this error message in the browser console:

cable.js:18 WebSocket connection to 'wss://sigma013.heliohost.org/cable' failed: 

Sadly, it's not giving much more detail than that.

Reading through another thread (https://helionet.org/index/topic/29870-java-websocket-on-tommy-default-ports-debugging-general-help/) it looks like it may be something that I can try to get working via an `.htaccess` file in my `public_html` folder, but so far my attempts have not worked.  Here's what I have so far (in `/public_html/.htaccess`)

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sigma013\.heliohost\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sigma013\.heliohost\.org$
RewriteRule ^cable\/(.*) "ws\:\/\/127\.0\.0\.1\:8080\/cable" [P,L]
RewriteRule ^cable\/(.*) "wss\:\/\/127\.0\.0\.1\:443\/cable" [P,L]

I modified the configuration found in the thread to match the path of that ActionCable is apparently trying to use (IE, instead of "sockets" I have "cable"), but I'm not sure what else I may be overlooking.  I'm still trying to wrap my brain around what should be in the .htaccess file.

I wondered if it's related to the secure socket (using .wss), but if I try the configure my app to use "ws://" instead, it gives me an error saying that you cannot create an insecure websocket from a secure webpage (since the main page itself is using https).

I'm hoping whatever change is needed is relatively small, and that I'm just overlooking something with the patterns or something, but any help or inisight provided woudl be greatly appreciated!

Posted

The purpose of Passenger is to load the Ruby app only when the website is accessed, and then unload it when there are no page hits to reduce CPU and memory usage for an unused app.

The purpose of a websocket is to keep a long running connection open in order to reduce the overhead of creating stateless https connections over and over.

The reason it's not working is because they are doing the opposite things, plus the port that your Ruby app runs on doesn't matter because Passenger intercepts any connections, and .htaccess can't redirect to the port that Passenger is blocking.

So you need to do one of two things:

  1. Don't use Passenger and run your Ruby app as a constantly running process. The downsides to this is your memory and CPU usage will spike massively. We only allow 100 GB of memory per day on Johnny and Tommy. If your Ruby app uses more than about 71 MB at a time you'll exceed the memory limit. Another downside is it's difficult to start and stop your Ruby app without SSH access, but not impossible and if you decide to try this we can help set it up.
  2. Switch to a VPS. https://heliohost.org/vps/ You get root SSH access, and 1 GB of dedicated memory, which will make websockets and Ruby much easier.
Posted

Thanks for the reply.  This particular app is a short-term one, but I think the signs keep telling me a VPS may be the better option for this, so I think I'll go that route!

I appreciate your help!

  • Krydos changed the title to [Solved] Ruby ActionCable and Websockets
  • Krydos locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...