sending mail in cloud9.io - node.js

I am running a sails.js project using nodemailer locally which is working well.Nodemailer use Smtp and Gmail's service.Problem is when i transfer my project on cloud9 it is blocking mail.
smtpTransport = nodemailer.createTransport('SMTP', {
host: 'smtp.gmail.com',
port: 25,
service: 'Gmail',
auth: {
user: model.sender,
pass: model.password
}
});
here is configurations and error is:
{ [Error: connect ETIMEDOUT]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
stage: 'init' }
from different searches i got that c9.io isn't supporting smtp.if it is true then how can i use nodemailer with c9 to send mails to gmail account.
on port 465 it gives this error
{ [AuthError: Invalid login - 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbv2r
534-5.7.14 5eXedgG1jE_vYL7r- o5CxdrMS5XlCbdbloPcENHa08v5fCwuvs7oM9ztAhkUh6RHfRvcBp
534-5.7.14 Qcpg_pdi-2E3Z9m1ipIvu4SZViMJABSDq3XWCMeLzlDfyS3C0JhoY7ldwRxsl3CZ67dvGQ
534-5.7.14
name: 'AuthError',
data: '534-5.7.14 <https://accounts.google.com/ContinueSignIn? sarp=1&scc=1&plt=AKgnsbv2r\r\n534-5.7.14 5eXedgG1jE_vYL7r-o5CxdrMS5XlCbdbloPcENHa08v5fCwuvs7oM9ztAhkUh6RHfRvcBp\r\n534-5.7.14 Qcpg_pdi-2E3Z9m1ipIvu4SZViMJABSDq3XWCMeLzlDfyS3C0JhoY7ldwRxsl3CZ67dvGQ\r\n534-5.7.14 S7PQL4xbl4No8jS_2ZVMnlNO5iYfZ7O9tTe8S1bu3DnkFwjWNNzvLBZ3zK_pzIfMRnH566\r\n534-5.7.14 sEij4Iu9_U6V4g9tCuXH5i87nWYc> Please log in via your web browser and\r\n534-5.7.14 then try again.\r\n534-5.7.14 Learn more at\r\n534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 k6sm6950159wia.6 - gsmtp',
stage: 'auth' }
on port 587 it gives this error
{ [Error: 140581811607424:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:795:
] stage: 'init' }

Google Compute Engine does not allow outbound connections on ports 25, 465, and 587 but you can still set up your instances to send mail through ports 587 and 465 using servers provided through partner services, such as SendGrid.
https://cloud.google.com/compute/docs/tutorials/sending-mail
Since Cloud9 workspaces are hosted on GCE, you'll have to use the supported partner services as detailed in the above document.

Related

Access database on Server with localhost node Project

I have bought a VPS for my website. I have built a small project with vue and node.
In this I used postgresql that is working fine on localhost.
I want to change my database from localhost to the server database where I have installed postgres and made a database and table.
My db.js file looks like this:
const Pool = require('pg').Pool;
const pool = new Pool({
user: "postgres",
password: "root",
database: "todo_database",
host:"45.111.241.15",
port: 5432
});
module.exports = pool;
Then I tried to send form data from the localhost vue page and it gave the following error:
error connecting db Error: connect ECONNREFUSED 45.111.241.15:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '45.111.241.15',
port: 5432
I do not have much knowledge about this and how to solve this.
Can you please guide me what should I do to connect with my server db?
I follow these steps and it worked:
edit your /etc/postgresql/9.1/main/postgresql.conf and change
Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
In /etc/postgresql/10/main/pg_hba.conf
IPv4 local connections:
host all all 0.0.0.0/0 md5
Now restart your DBMS
sudo service postgresql restart
Now you can connect with
psql -h hostname(IP) -p 5432 -U postgres

Docker container connection to host's Kafka throws : Error: connect ECONNREFUSED 127.0.0.1:9092

I have a nodejs app containerized as a linux container which uses the kafka-node library.
Kafka runs on the host machine which runs windows with:
Zookeeper port : 2181
Kafka broker port : 9092
I run the the nodejs container with the following command:
docker container run --network host --name nm name:1.0
In order to connect with the host's kafka I am using the following command:
client = new kafka.KafkaClient({kafkaHost: "localhost:9092"});
But this throws :
Error: connect ECONNREFUSED 127.0.0.1:9092
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1126:14) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9092
}
When I change the connect command to :
client = new kafka.KafkaClient({kafkaHost: "host.docker.internal:9092"});
I am getting :
TimeoutError: Request timed out after 30000ms
at new TimeoutError (/usr/src/app/node_modules/kafka-node/lib/errors/TimeoutError.js:6:9)
at Timeout._onTimeout (/usr/src/app/node_modules/kafka-node/lib/kafkaClient.js:491:14)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
message: 'Request timed out after 30000ms'
}
Can someone advise what I am doing wrong ?
UPDATE
When switching to a linux host machine, the above localhost methodology runs just fine .
Same problem here, but I can solve
You must set the environment variable KAFKA_ADVERTISED_HOST_NAME with your domain host.docker.internal:9092 in Kafka broker
My example:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
hostname: 'kafka-internal.io'
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka-internal.io
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Now I can connect inside container using kafka-internal.io:9092 :)
Not the best answer but switching to a Linux host should make the first methodology (localhost:IP) run just fine .

Connection with SQL Server 2014 with node js

I am unable to connect to my SQL Server 2014 from node server.
I get this error:
Failed to connect to 192.168.1.3,2207:2207:1433 - getaddrinfo ENOTFOUND 192.168.1.3,2207:2207'
TCP port also enabled but same issue
By using knex i resolve this problem
connection: {
server : 'IP Address',
user : 'sa',
password : '******',
database : '*****',
options: {
port: 14831
}
}

ssh2 timed out while waiting for handshake in nodejs

I am trying to upload a file using ssh in my nodejs application, while trying, I am getting error as "connection error: timed out while waiting for handshake". gave connection setting as,
....
}).connect({
host: 'hostname without http',
port: 22,
debug: console.log,
readyTimeout: 99999,
username: 'name',
password: 'password'
});
If I upload manually to the server it is working fine with the given hostname, username and password.

isSSL false even though I've set tls to True when sending mail

I'm trying to use an external smtp server from my springboot-application (scaffolded by JHipster). I have set the folling in my applocation.yml, and it picks up everything except the SSH settings.
host: send.one.com
port: 465
username: user#name
password: password
protocol: smtp
tls: true
auth: true
from: user#name
When i run the app I can see the following in my log
[DEBUG] com.sun.mail.smtp - useEhlo true, useAuth true
[DEBUG] com.sun.mail.smtp - trying to connect to host "send.one.com", port 465, isSSL false
[DEBUG] com.sun.mail.smtp - EOF: [EOF]
[DEBUG] com.sun.mail.smtp - could not connect to host "send.one.com", port: 465, response: -1
it seems the application is trying to connect without ssl, and it won't connect. What am I doing wrong?
You try to send over TLS. In general the standard port used by TLS is 587 and not 465 which is used for SSL. Try whether it works with that port?

Resources