Hello,
I have a website that uses socket.io to send chat messages, in local it works great, and some time ago I managed to make it work in a server through https.
Now that I have started using Cloudflare, I have noticed that the chat service has stopped working and I have been trying for several days to find a solution but without success.
The code is the following:
On server:
const fs = require('fs'),
options = {
key: fs.readFileSync('/etc/letsencrypt/live/domain.net/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/domain.net/cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/live/domain.net/chain.pem')},
app = require('express')(),
server = require('https').Server(options, app),
allowedOrigins = '*:*',
io = require('socket.io')(server, {origins: allowedOrigins, wsEngine: 'ws'});
server.listen(2053, function(){
console.log('listening on *:2053');
});
app.get('/', function(req, res){
res.send('server is running');
});
On client:
this.basicSo = io.connect("https://beta.domain.net:2053", { secure: true, query: {userID:'miuserID'} });
this.basicSo.on('connect_error', this.connect_error.bind(this));
this.basicSo.on('connect', this.basic_authenticate.bind(this));
private connect_error():void{
console.log("connect error");
}
private basic_authenticate():void{
this.basicSo.emit('authenticate', {pass:this._kHandshakeChat});
}
When I open the client, I continuously receive the log of “connect error”
In fact I am not able to see anything when I write in the browser https://beta.domain.net:2053 and i think i should see the message ‘server is running’
<IfModule mod_ssl.c>
<VirtualHost *:2053>
DocumentRoot "/opt/ChatServer"
ServerName beta.domain.net
ErrorLog "/var/log/httpd/domain_beta_chat_log"
CustomLog "/var/log/httpd/domain_beta_chat_log" common
<Directory /opt/ChatServer>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain.net/chain.pem
</VirtualHost>
</IfModule>
When i run sudo firewall-cmd --zone=public --list-ports i see
2053/tcp
Can someone help me?