Exlord
Exlord

Reputation: 5371

Node.js can't reacive data from telegram bot websocket

I am trying to set up a telegram bot with nodejs https server with self singed certificate.

ssl certificate:

openssl req -newkey rsa:2048 -sha256 -nodes -keyout key.pem -x509 -days 365 -out crt.pem -subj "/C=IR/ST=A.Sh/L=Tabriz/O=DominoSystem/CN=5.235.36.42"

The very simple server:

var options = {
    key : fs.readFileSync(__dirname + '/key.pem'),
    cert: fs.readFileSync(__dirname + '/crt.pem')
};

https.createServer(options, function (req, res) {
    console.log('https server');
    console.log(req.url);
    res.end('yoo hooo');
}).listen(8443,'0.0.0.0');

The server is accessible from internet : https://5.235.36.42:8443/

Telegram bot setWebhook returns ok {"ok":true,"result":true,"description":"Webhook was set"}

I can see in my filewall logs and DU Meters "Open TCP Connections" that nodejs.exe is receiving a connection from one of telegram's data centers and it always have the status ESTABLISHED and sometimes SYN_RCVD and then closes with send&receive=0KB but my nodejs server is not receiving any requests.

I have allowed my firewall(Comodo) to ACCEPT all incoming connections on port 8443.

I have been bashing my head around for 2 days now :( can someone help me pliz...

Windows 8.1 x64, Nodejs 5.9.1

Upvotes: 1

Views: 1041

Answers (1)

Exlord
Exlord

Reputation: 5371

OK, fixed it myself, it seems that Telegram didn't like the certificate generated by openssl on windows (8.1).

I generated the certificate on my linux (CentOS6) server and now it works :D, both in the server and in the local dev machine.

Upvotes: 1

Related Questions