Connect to Juggernaut with Ruby - ruby

require "juggernaut"
Juggernaut.publish("channel1", "Some data")
The code above works if Juggernaut is on the same server as the one running the code. What's the syntax to use a Juggernaut running on another server?

The syntax is the same. I have a juggernaut.yml config file in my config directory with settings for each environment. To run juggernaut on port 8080 of localhost in development, I have:
development:
host: 'localhost'
port: 8080
To run it on a different host, you can just change that host setting (e.g. 'jugg.someserver.com')

Related

DDEV: How to etablish websocket connections

I'm having some problems to establish a websocket connection to a running ddev container.
Trying wo etablish the connection per JS for example with wss://websocket.ddev.site:3000 ends always up with connection failed.
Websocket PHP library used: Ratchet (http://socketo.me/)
I tried to set the ext. container port in an own docker-compose.yaml or web_extra_exposed_ports in config.yaml but nothig worked so far.
I have managed to run a Websocket connection.
Therefore, I did an entry in config.yaml of DDEV with following Content:
web_extra_exposed_ports:
- name: ratchet
container_port: 3000
http_port: 3000
https_port: 3001
After DDEV restart, it is now possible to establish a Websocket connections with:
HTTP: 'ws://websocket.ddev.site:3000'
HTTPS: 'wss://websocket.ddev.site:3001'
My working example was build with the tutorial on http://socketo.me/docs/hello-world calling above URL with Browser console.

Error > Could not connect to Cloud Shell on port 8080 > While connecting the Visual Code using code-server

Trying to install Visual Code IDE in VM Instance. After running the code-server, while checking view on browser, it is giving an error.
Error: Could not connect to Cloud Shell on port 8080.
Ensure your server is listening on port 8080 and try again.
enter image description here
reference link to install VS Code in GCC:
https://medium.com/google-cloud/how-to-run-visual-studio-code-in-google-cloud-shell-354d125d5748
Try openning on your browser:
http://[your-external-ip]:8080/
Its important to change the default "https" to "http".
I also added the port 8080 on my firewall permisions on gcp.
You should set your host to 0.0.0.0. When you start the server, your command could be like this:
./code-server --no-auth --port 8080 --host 0.0.0.0
And everything should work fine. Try it :D

How do I enable remote access/request to Elastic APM-server?

I have setup of Elastic with APM server on single machine. I've configured APM java agent to push traces to APM server on localhost. Everything works fine with localhost configuration on Windows.
Now, I'm looking to run apm java agent for application running on different machine on the same network. That is apm java agent on linux & apm server running on windows machine.
Default APM-server listen to localhost. I tried to change setting on apm-server.yml file with -
apm-server:
# Defines the host and port the server is listening on. use "unix:/path/to.sock" to listen on a unix domain socket.
host: "hot-ip:8200"
default is:
host:"localhost:8200".
After making apm-server.yml change, process explorer show apm-server.exe process listening to IP- host-ip port- 8200 protocol- TCP.
But, still http://host-ip:8200 is not accessible from other machine on network. While on the same machine (windows) http://localhost:8200 & http://host-ip:8200 works fine & give below response.
{
build_date: "2019-05-23T12:58:36Z",
build_sha: "410bf33fa1b67fa5bd02a388de17d0e30ec031da",
version: "7.1.1",
}
Thanks for help.
To listen on 0.0.0.0 try:
host: ":8200"
Is a firewall blocking the traffic (like Window's built-in one)?
10.9.21.91 is the IP that hosts are trying to reach? Just to be sure you could bind to host: "0.0.0.0:8200", which would cover all possible interfaces.
Replace "localhost:8200" with "0.0.0.0:8200" in apm-server.yml

Problems with configuring Lando on Fedora (on Linode) to port 80

I have been trying to configure lando to expose my container to public domain that is pointing there. So my domain, lets call it my_app.com, is showing The random port assignments to the container work from the domain but not I am not able to fix it to port 80.
For example Lando starts up and shows these available URLs
APPSERVER URLS https://localhost:32781
http://localhost:32782
http://my_app.lndo.site
https://my_app.lndo.site
When I navigate to my domain, my_app.com, it doesn't' work, but if I use my_app.com:32781, it does.
I feel like I am missing something simple. The server itself is a fresh installation of Fedora 29 with Lando v3.0.0-rc.8
My Lando file:
name: my_app
recipe: drupal8
config:
webroot: ./drupal/web
php: 7.2
port: '8080'
drush: ^9
xdebug: false
event:
post-rebuild:
- composer install -d=./drupal
Per https://docs.devwithlando.io/config/proxy.html, adding the following lines to your .lando.yml should configure Lando to properly route your custom domain. Port 80 will be bound automatically unless some other service on your machine is already using the port.
proxy:
appserver:
- my_app.com
You mention a .com domain. Apparently you want your app to be publicly (WAN) accessible. Are you behind any router? Then simply open a port and direct it to your computer IP and your 32782 for http which is port 80 for the outside world. In some routers this is called "Port mapping".
The firewall on your computer needs to have the port 32782 opened. You might need to include share.

Can't access Ruby server on VM from host machine

I have a VM set up running Ubuntu server 14.04. In my VM I have created the following Ruby/Sinatra app:
require 'sinatra'
set :environment, :production
set :bind, '0.0.0.0'
get '/' do
"Hello World!"
end
When I execute this using ruby hello.rb I get the following output:
[2015-03-09 16:58:34] INFO WEBrick 1.3.1
[2015-03-09 16:58:34] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
== Sinatra/1.4.5 has taken the stage on 4567 for production with backup from WEBrick
[2015-03-09 16:58:34] INFO WEBrick::HTTPServer#start: pid=2258 port=4567
Everything seems to work fine, but when I try to access localhost:4567 from my host machine (Windows 8.1) I get a GET http://localhost:4567/ net::ERR_CONNECTION_REFUSED error (in Chrome).
If I try to access the server from within my VM (ex, by using wget http://localhost:4567) it works fine.
I also have Apache2.4 running in my VM, which works fine, but I disabled it when trying to access my Ruby server by running sudo service apache2 stop.
What could the problem be? I have no problem running regular Ruby files, and I can access my Ruby/Sinatra app if I use Apache2 with Phusion Passenger. But when I simply run ruby hello.rb I can't access it from my host machine.
localhost refers to your local host, which in the case of Windows is not the same as your Ubuntu instance.
You'll need to connect to your Ubuntu instance IP directly, whatever that is. Usually you can find out with ip addr or ifconfig.
If you need a friendly DNS name you can put in your browser, xip.io provides one.
If you're using Vagrant then you can configure port forwarding so you can still use localhost if you want. Without port forwarding you will not be able to connect indirectly.
I have the network adapter for my VM attached to NAT. I was forwarding ports 443, 22 and 80 to my VM, and accessing my server on those ports works fine. Since I was running the Ruby WEBrick server on the default port 4567, I just had to forward port 4567 from my host machine to my VM as well.
After that change, typing http://localhost:4567 into my web browser served up the content from my Ruby file.

Resources