Erlang Web and Inets BindAddress - erlang

After installing Erlang Web 1.3 and starting it in interactive mode, I get the following error in the logs:
Failed to start service:
"config/inets.conf"
due to: "httpd_conf: 0.0.0.0 is an
invalid address"
In my inets.conf I have the following:
BindAddress 0.0.0.0
My sys.config:
[{inets,[{services,[{httpd,"config/inets.conf"}]}]}].
Any suggestion?

I fixed the problem by myself.
I just changed the BindAddress line in inets.conf into:
BindAddress *

This configuration directive is being parsed and validated by httpd_conf, which in turn calls httpd_util:ip_address/2. Both of these were changed in R13B02. Have you tried with that Erlang/OTP version?

i have no experience with this language or situation, but it looks like that 0.0.0.0 is an invalid address, have you tried changing it to something like 127.0.0.1 ?

Related

Cloud9 Rails API challenge: allowed network but still cannot render console

I am following along with this Treehouse Build a Rails API course. I am using Cloud9 IDE which I think is related to the problem. The step I am stuck on is creating a new list via the API in the console.
At first I was receiving an error message saying "cannot render console" from the network. After googling this, I whitelisted the network in the development.rb file. The error message is different and so I believe I properly whitelisted it (or at least did something). But it does not have the desired effect and the error message seems to contradict itself.
Started POST "/api/lists" for 123.456.78.999 at 2015-09-14 14:53:33 +0000 Cannot render console from 123.456.78.999! Allowed networks: 123.456.78.999, 127.0.0.0/127.123.123.123, ::1
I've changed the numbers because I am not savvy about security. The point (and to me, the mystery) is that it says I can't render the console from a network that is apparently allowed (i.e., 123.456.78.999 === 123.456.78.999).
I would appreciate any advice on what could be the problem. I had no trouble following along with the tutorial until this step; the commands I entered led to the same result as in the videos.
This is the most recent command I've entered:
curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"title":"The Title will go here"}' https://myapp-me.c9.io/api/lists
Entering that URL instead of "localhost" has worked for me thus far but it could also be related to the problem.
Thank you for any clues and happy to post additional code if needed.
please add in config/enviroments/development.rb
config.web_console.whitelisted_ips = '0.0.0.0/0.0.0.0'
To whitelists 2 IPs > Consider this example:
config.web_console.whitelisted_ips = %w( 127.0.0.1 10.0.0.9 )
To whitelist an entire IP subnet > Consider this example:
config.web_console.whitelisted_ips = %w( 127.0.0.1 10.0.0.0/24 )
always add 127.0.0.1, or else the local machine won't have access.
If anyone is still viewing this question in 2022 like I am, then you can edit config/environments/development.rb to account for the entire private network like so:
Rails.application.configure do
.
.
.
config.web_console.permissions = '123.456.78.0/16'
end
More information here.
Part of the problem is that you need to be within the "sudo su" shell in order to run Ruby on Rails applications. So, make sure that you run sudo su and you become root. The second problem is that you MUST run your application on port 8080 so when you run the server make sure the -p 8080 flag is set:
bundle update (optional)
bundle install (optional)
sudo su
rails s -p 8080
New terminal --> Preview --> Preview running application

Deployd dpd "app" - listening on port then goes right to "bye"

I had deployd running just fine on my MAC OS, then I let it sit for a couple weeks.
Went back to it, launching the Deployd server with "dpd app_name"
I get the following:
listening on port 2403
type help for a list of commands
dpd > bye
I've tried to install/reinstall multiple times, it's doing it also on all deployd website examples.
I've tried changing the port, no luck
I've looked for an error log file. Couldn't find any.
I tried to go on Chrome and Safari, same thing: "Connection Refused".
Any idea, anyone?
Thanks in advance!
That happened to me, just type sudo before dpd.
$ sudo dpd
If you run:
$ DEBUG=* dpd
inside the app folder you will probably see the problem is with mongod, and run with sudo solves it.

unable to start rabbitmq-server

I installed rabbitmq using homebrew. I am trying to start rabbitmq server but I always get this error which I am unable to figure out why!
I have erlang installed and there is no other application running on the same port.
$ rabbitmq-server
{error_logger,{{2013,2,11},{22,37,49}},"Can't set short node name!\nPlease check your configuration\n",[]}
{error_logger,{{2013,2,11},{22,37,49}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,320}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}},{ancestors,[net_sup,kernel_sup,]},{messages,[]},{links,[]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,24},{reductions,249}],[]]}
{error_logger,{{2013,2,11},{22,37,49}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[[rabbitmqprelaunch1593,shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2013,2,11},{22,37,49}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
{error_logger,{{2013,2,11},{22,37,49}},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}"}
Crash dump was written to: erl_crash.dump
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}})
btw, erl -sname abc gives the same output
Update:
This is what I have in /etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
check your computer name and your short host name or alias name in /etc/hosts, match this
Check your computer name [wendy#nyc123]$
nyc123 is your computer name
Check your short hostname
[wendy#nyc123]$ hostname -s
[wendy#nyc123]$ nyc456
This error could happen because your computer name and short host name didn't match. To match this, you can change the computer hostname or alias name.
Change computer host name
[wendy#nyc123]$ hostname nyc456
close your terminal and open again
[wendy#nyc456]$
the computer name has changed
or
Change alias name in /etc/hosts
127.0.0.1 nyc123.com nyc123
save and check again
[wendy#nyc123]$ hostname -s
[wendy#nyc123]$ nyc123
Restart your rabbitmq!
[root#nyc123]$ rabbitmq-server start</p>
RabbitMQ 3.6.0. Copyright (C) 2007-2015 Pivotal Software, Inc.</p>
## ## Licensed under the MPL. See http://www.rabbitmq.com/</p>
## ##</p>
########## Logs: /var/log/rabbitmq/rabbitmq#nyc123.com.log</p>
###### ## /var/log/rabbitmq/rabbitmq#nyc123.com-sasl.log</p>
##########</p>
Starting broker... completed with 6 plugins.</p>
I looked for a similar error on google, and it looks like it can happen if your /etc/hosts file is in the wrong format. Try fixing it and see if that helps.
References:
http://www.ejabberd.im/node/18
Explanation on RabbitMQ Mailing list
Edit: For completeness, it seems like setting a long name (of the form abc#abc) worked.
Found the answer here:
control rabbitmq 'name' not 'sname'
Set your machine name to something simple and make it an alias to locahost
I also encountered this problem yesterday and found the root cause:
I had changed my system's hostname to a "long" name, pm3(hc desktop).
If your server's hostname is long or invalid, Linux can still work and no error message is prompted to you. As you just modify the /etc/hostname file and reboot. However, the rabbitmq server may not work and give this "short-name" error message to you.
I changed hostname back to "pm3", rebooted and everything went well.
I solved this issue changing the computer name (on windows 8.1). The problem was that the name had a strange character (é) spanish letter. My computer name was Andrés and I changed it to Andres, restarted my computer and everything worked well. I think that Rabbit could not recognize that name (Andrés) for that strange character.
remove old style config file /etc/rabbitmq/rabbitmq.config
and use rabbitmq.conf
with listeners.tcp.default = 5672
after that restart rabbitmq server again
In my case that solved the issue in ec2 instance

Jenkins SMTP TLS

I'm trying to setup Jenkins to use our company's SMTP server to email build notifications. We are using TLS as the encryption method on port 587. I can not seem to get the email notification to work properly though.
Here is my Hudson.Tasks.Mailer.xml file so you can see my config (I've removed the SMTP auth user and password and changed the smtpHost slightly just in case)
<hudson.tasks.Mailer_-DescriptorImpl>
<helpRedirect/>
<defaultSuffix></defaultSuffix>
<hudsonUrl>http://localhost:8080/</hudsonUrl>
<smtpAuthUsername></smtpAuthUsername>
<smtpAuthPassword></smtpAuthPassw$
<adminAddress></adminAddress>
<smtpHost>pod#####.outlook.com</smtpHost>
<useSsl>true</useSsl>
<smtpPort>587</smtpPort>
<charset>UTF-8</charset>
</hudson.tasks.Mailer_-DescriptorImpl>
It looks like this is a known issue, from http://issues.hudson-ci.org/browse/HUDSON-2206
I am not very familiar with Apple OS (which is the machine that is running Jenkins) but I thought I could resolve the issue using the workaround mentioned. I wasn't exactly sure where to put that workaround though, so I tried putting it here:
/Library/Application Support/Jenkins/jenkins-runner.sh
defaults="defaults read /Library/Preferences/org.jenkins-ci"
war=`$defaults war` || war="/Applications/Jenkins/jenkins.war"
javaArgs="-Dmail.smtp.starttls.enable=\"true\""
heapSize=`$defaults heapSize` && javaArgs="$javaArgs -Xmx${heapSize}"
permGen=`$defaults permGen` && javaArgs="$javaArgs -XX:MaxPermSize=${permGen}"
home=`$defaults JENKINS_HOME` && export JENKINS_HOME="$home"
add_to_args() {
val=`$defaults $1` && args="$args --${1}=${val}"
}
args=""
add_to_args prefix
add_to_args httpPort
add_to_args httpListenAddress
add_to_args httpsPort
add_to_args httpsListenAddress
add_to_args ajp13Port
add_to_args ajp13ListenAddress
echo "JENKINS_HOME=$JENKINS_HOME"
echo "Jenkins command line for execution"
echo /usr/bin/java $javaArgs -jar "$war" $args
exec /usr/bin/java $javaArgs -jar "$war" $args
That didn't appear to resolve it. I can see that call in the console when Jenkins is started up, but when I try a test configuration email I get the following error:
Failed to send out e-mail
javax.mail.MessagingException: Could not connect to SMTP host: pod#####.outlook.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
Any ideas on what else I can try? I've tried switching the email account to use gmail's smtp server and that works fine, but I'd rather have it using our smtp server if I can.
Changing the SMTP port from 587 to 465 resolved this issue for me:
SMTP server: smtp.mandrill.com
Use SMTP Authentication: true
Use SSL: true
SMTP Port: 465
From what I can tell (disclaimer: I am by no means a Hudson/Jenkins expert)
the Hudson/Jenkins email plugin supports SSL encrypted SMTP communication - however this implementation requires that communications are encrypted from the get go.
When connecting on port 587, the server on the other end may expect a STARTTLS command (see this SSL vs TLS vs STARTTLS article). This command is sent using plain-text to 'upgrade' the connection to use SSL/TLS.
Hudson/Jenkins instead attempts to start negotiating SSL on port 587, which is promptly rejected, resulting in the following error:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
I tried adding the suggested JAVA options "-Dmail.smtp.starttls.enable=true" to enable TLS:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
Unfortunately this didn't resolve the issue for me.
After changing the port to 465, the SSL negotiation occurred correctly and the communication succeeded.
Hope that helps.
Note: Jenkins email plugin always needs SMTP credentials that are often sender's email credentials when you checkmark "Use SMTP Authentication" option for any "SSL - port 465" or "non SSL - port 587" configuration.
I had the same issue with Jenkins but mine is installed on Centos rather than Apple OS. I still thought to post the solution here because A) you might be able to make the needed adjustments to the solution and B) Linux & Jenkins users might benefit from this.
Anyhow, find the Jenkins configuration file (in CENTOS its in /etc/sysconfig/jenkins)
In it locate the JENKINS_JAVA_OPTIONS variable and add the following option "-Dmail.smtp.starttls.enable=true"
In my case this is what I had before:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
And this is after;
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
restart Jenkins server (in Linux)
/etc/init.d/jenkins restart
For Jenkins on Windows
Open jenkins.xml and modify the arguments node
-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dmail.smtp.starttls.enable=true -jar "%BASE%\jenkins.war" --httpPort=8080
For smtp.live.com:
Set the SMTP port to 587 and uncheck Use SSL
Even after setting -Dmail.smtp.starttls.enable=true as mentioned in #nsof's answers in the file /etc/default/jenkins (debian/ubuntu), it did not work for me.
The trick was to set the SMTP port to 587 and uncheck Use SSL as show below, then the email was sent successfully.
Try out the workaround mentioned in the bug itself:
http://issues.hudson-ci.org/browse/HUDSON-2206
In Java:
props.put("mail.smtp.starttls.enable","true");
In Tomcat:
Add JAVA_OPTS=-Dmail.smtp.starttls.enable="true" to tomcat config file.
Adding -Dmail.smtp.starttls.enable=true as arguments of JAVA_OPTS solved my problem
If your jenkins is running in stand alone mode update JAVA_OPTS in /etc/sysconfig/jenkins
If your jenkins is running in tomcat update JAVA_OPTS
catalina.sh for unix
catalina.bat for windows
For Jenkins on Ubuntu 16.04:
1 - Edit the config file:
sudo nano /etc/default/jenkins
2 - Comment out existing JAVA_ARGS, add new one shown below:
#JAVA_ARGS="-Djava.awt.headless=true"
JAVA_ARGS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
3 - Restart Jenkins
sudo service jenkins restart
For Jenkins on Red Hat Enterprise Linux Server release 7.4 (Maipo)
edit /etc/sysconfig/jenkins to add
The Jenkins service configuration file requires root access to the machine.
In CloudBees Jenkins Enterprise, you can find this file under:
/etc/default/jenkins: location for most of the Linux distributions.
/etc/sysconfig/jenkins: location for RedHat/CentOS distribution.
C:\Program Files\Jenkins\jenkins.xml: default location for Windows
With Jenkins 2.134 the following worked for me:
JAVA_TOOL_OPTIONS=-Dmail.smtp.starttls.enable=true
Uncheck Use SSL!
This is the best possible solution in case none of the above solutions work.
https://issues.jenkins-ci.org/browse/JENKINS-47939
Following a statement in #user11791348 's answer resolved the issue for me.
The statement was: "It is IMPORTANT to note that BOTH the "E-mail Notification" section User Name AND the "Jenkins Location" section System Admin e-mail address must be valid smtp.office365.com users. If either one is not found in smtp.office365.com, you will get a "Client does not have permissions to send as this sender" error"
So, I configured System Admin e-mail address in Jenkins, Also my Jenkins.xml contains the line:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Djava.awt.headless=true -Dmail.smtp.starttls.enable=true -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8080 --webroot="%LocalAppData%\Jenkins\war"</arguments>
Use SSL: Unchecked
Use TLS: Unchecked
SMTP Port: 587
If Jenkins is configured as a systemd service, it seems that the $JAVA_OPTS are not picked up from /etc/default/jenkins, but rather from the systemd unit file itself.
On Debian, I edited /lib/systemd/system/jenkins.service and modified the JAVA_OPTS environment variable to the following:
Environment="JAVA_OPTS=-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
Then flush systemd and restart the Jenkins service:
sudo systemctl daemon-reload
sudo systemctl restart jenkins
You can verify that the correct options were picked up by navigating to ${JENKINS_BASE_URL}/systemInfo and searching for mail.smtp.starttls.enable
Fast forward 9 years and no workarounds are needed anymore thanks to Basil Crow.
The E-mail Extension plugin has support for SMTP over TLS and the additional "TLS" configuration checkbox (revealed by clicking on the Advanced button) since v2.83 released in May 2021 (see its release notes). I verified it works with Gmail under latest Jenkins and plugin versions.

RAILS, CUCUMBER: Getting the testing server address

While running a cucumber test, I need to know the local testing server address. It will be something like "localhost:47632". I've searched the ENV but it isn't in there, and I can't seem to find any other variables that might have it. Ideas?
I believe that the port is generated is dynamically generated on test runs. You can use OS level tools to inspect what connections are opened by process and glean the port that way. I do this on my ubuntu system infrequently so I can't tell you off the top of my head what tool does that. Netstat maybe? I always have to go out and google for it so consider this more of a hint than a complete answer.
Ah, to be more clear...I put a debug breakpoint in, and when it breaks THEN I use the OS level tools to see what port the test server is running on at that moment in time. How to discover it predictively? No idea, sorry.
here's what I use:
netstat -an | grep LISTEN
(Answering my own question just so that the code formatting will be correct)...
Using jaydel's idea to use netstat, here's the code. I extract the line from netstat that has the current pid. (Probably not the most elegant way to do this, but it works)
value = %x( netstat -l -p --tcp )
pid = $$.to_s
local_port = ""
value.split( "\n" ).each do |i|
if i.include?( pid )
m = i.match( /\*:(\d+)/ )
local_port = m[1].to_s
end
end

Resources