I want to create a feature on my web portal where a user can click a link to open a telnet session in the browser itself. I researched the Net::Telnet library for Ruby. It has information on how to set up the connection.
But what about the web UI?
How to leverage the Net::Telnet library on the rails web app.
I have Rails 4.2.0 with Apache Passenger running on a CentOS 6.6 machine.
Because telnet is a streaming/serial type protocol and users will expect that type of experience, you might want to look into websockets or streaming http. The only other option would be to do polling to keep your view updated which seems like a very bad fit for a telnet client. Definitely an interesting problem. It appears that Net::Telnet behaves like a tcp socket connection so if you can wire that up to an http stream, which seems possible, you should be able to push it to a browser UI. Sounds like a cool project. Let me know how it takes shape.
Related
I am using a ruby on rails app which goal is to handle lockers reservations by users and be able to unlock them using a smartphone.
The rails app is hosted on heroku (free plan), and I use several raspberry pi as remote servers that control opening of lockers.
So far, it works with HTTP requests from the app to the raspberry through a free http ngrok tunnel, but this is limited to a few requests per minute, and the connection is not secure/private at all, so it is not really what I need.
What type of solution would you recommend to ensure a more secure connection between the app and remote servers with no request number limitation ? I have a few concepts in mind, but I don't understand them well enough to know what I should look into. VPN ? SSH ? Web sockets ? Should I still use heroku ?
Thanks a lot guys!
You could achieve what you want with all technologies you listed above but I think using web sockets would simplify the setup process and it also seems to be the most robust.
Have a look at this client for your Raspberries.
To get the server to work you'll need a redis instance, which heroku offers in their free plan so you can keep it there. Your server app will need to use something like ActiveCable or faye.
I have a Red Hat server running tiger-vncserver.
This is a hardened system and security doesn't like having so many ports open for VNC users so currently we have 15 (5901-5915). We are getting more users onboarded and anticipate more users after, not sure how many though.
Is there a way to make every user have a stateful VNC connection available but share ports? From security's perspective, we would only use like port 5900 or something.
If it matters, I am using Apache Guacamole in lieu of a VNC Viewer client due to our configuration requirements.
The issue with VNC and multiple users is missing connection manager for VNC that could be able to handle user authentication and start a separate VNC server for each user.
We had similar issues with Guacamole and remote VNC session and it was possible to handle this with several scripts that we had to integrate into our solution. However, the script had to grow over time and needed to include more and more logic for all specific situations that might happen.
In the end, it turns out that installing XRDP server on a remote Linux is a much easier and quite consistent solution. It opens only one port, 3389 can manage connections and user and Guacamole work well with it, just you have to use RDP protocol.
I'm trying to add Guacamole (An html5 vnc client) to an existing rails project but I'm running into some trouble because the Guacamole server is implemented in Java. Based on the overview here http://guac-dev.org/doc/gug/writing-you-own-guacamole-app.html, I need to create 1. a GuacamoleHTTPTunnelServlet (a tunnel between the JavaScript client and the Guacd service) and 2. the javascript client itself. See attached picture for reference. Creating the javascript client seems easy because all the javascript is already given and I would just have to add it to a rails view. The hard part, if possible at all, is integrating the GuacamoleHTTPTunnelServlet java servlet with rails.
Is there any way to have rails serve up the javascript but have the javascript communicate with a different server on the same machine? I'm guessing no because of the same origin policy.
Is there any way to forward the javascript calls from rails server -> java servlet without losing performance? I'm not completely clear on how the javascript client communicates with the server but I think it's passing java objects.
I've never tried anything like this before so please excuse me for any stupidity.
I played around with guacamole and I think your best option is to rewrite guacamole backend (that comunicates with guacd daemon) in rails. Anyway I will try to answer to your questions:
You can proxy ajax requests with rack, ex:
How do I proxy AJAX requests with Rack Middleware?
Another way is to use a reverse proxy (nginx?), ex:
http://yourdomain.com/your/rails/view/url
http://yourdomain.com/guacamole
In this manner the client (browser) will think that your applications are under the same host, avoiding the javascript same origin policy. An iframe will be a great solution.
Javascript communicates with tunnel servlet that proxies requests to guacd daemon (no java objects, just a custom protocol). To speed up performances you can use a reverse proxy (answer 1, ex: nginx) instead of ruby/rack solution.
I hope this can help :)
I am new to the web socket framework with Rails and generally I feel I should get my hands to start working with it. I have used Faye for my private message publishing and it works nicely. So I want to ask if there is a nice tutorial out there that can show me how to use web sockets with rails. Thank you.
Node.js + socket.io is probably your easiest option right now. Faye is set up to use Node.js, so you may have already have Node.js running alongside your rails app (depending on how you're using Faye). You'll just want to start using socket.io. The socket.io repo includes some very useful examples - I sugget looking at chat.
You can communicate between your rails app and Node.js server via http. Node.js lets you easily make an http server. You may also want to take a look at request.
I need to write a Rails application (JRuby) that does asynchronous communication with another service in the background. There needs to be one connection per browser session. (It does not really need to be a open TCP connection but I need to free resources after the session ends.) The communication with the background service is not strict request - response. At any time there can be a message sent from the service to the rails app.
I also need to implement the protocol. How do I do this? Is there a asynchronous framework (e.g. like Twisted or Node.js) for Ruby on Rails? I just need some starting points.
I already wrote a quick implementation of the client side protocol in Python. In fact the complete protocol is made up by me (the server is written in JavaScript), so I could change the protocol completely. However, the asynchronous nature cannot be changed because of the nature of the problem.
Also I need XHR polling/WebSockets in order to push the async changes to the browser. Is there a gem/howto/tutorial for that? I can't just set the request to sleep (resources!).
In case you want to know more about the background:
The Rails application is a accessibility tool. The service with which it communicates is actually a Firefox Add-on that loads and renders webpages. The asynchronous nature comes from (i)frames, popup windows (window.open(), window.alert(), ...), dynamic changes to the DOM tree that have to be communicated to the Rails app, redirects (like after posing in a forum) etc. I need to use JRuby because I need to use the Jena (Java) framework for RDF processing.
Ruby On Rails is an asynchronous framework too. with a thin server. Node.js or Twisted are not a Asynchrone framework. There just Event framework.
In ruby the Event Framework is EventMachine and thin serveur use it. You can create some websocket with a rack::middleware and use it.
Have a look at Juggernaut 2, it does exactly this (and it also uses node). I am using it to push messages from my server to all connected clients and it works great. Implementation was a breeze (although the readme is a bit unclear on certain things), lemme know if you need any help with it.