[英]using https with express io
So I am new to express and io but I had a server running fine for webRTC but now there is a deprecated method in webRTC that only runs on https so I tried to create an https server but it starts and then immediately exits. 所以我是新来表达和io,但我有一个服务器运行良好的webRTC但现在webRTC中有一个弃用的方法只运行在https所以我试图创建一个https服务器,但它启动,然后立即退出。 I cannot figure out what is wrong and I do not get any errors.
我无法弄清楚出了什么问题,我没有得到任何错误。 Also I am using an aws ec2 to run the express io server.
我也使用aws ec2来运行快速io服务器。 Maybe someone can spot where in my syntax/implementation I am going wrong.
也许有人可以发现我的语法/实现中哪里出错了。
Note I have been googling around for the past half hour and cannot figure it out 注意我过去半小时一直在谷歌搜索,无法弄明白
Here is the code: 这是代码:
var connect = require('connect');
var https = require('https');
var fs = require('fs');
var express = require('express.io');
var app = express();
//app.http().io();
var PORT = 443;
var options = {
key: fs.readFileSync('../server.key'),
cert: fs.readFileSync('../server.crt')
};
app.https(options).io();
//var app = https.createServer(options, app1);
console.log('server started on port ' + PORT);
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res){
res.render('index.ejs');
});
app.listen(PORT);
app.io.route('ready', function(req) {
req.io.join(req.data.chat_room);
req.io.join(req.data.signal_room);
app.io.room(req.data).broadcast('announce', {
message: 'New client in the ' + req.data + ' room.'
})
})
Update 更新
I am putting a bounty on this because I would like someone to provide me with a complete answer on setting up the server for production. 我对此表示赏心悦目,因为我希望有人能够为我提供有关设置生产服务器的完整答案。
You need to add a rule for port 443 in a Security Group for your instance. 您需要在实例的安全组中为端口443添加规则。
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html might help. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html可能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.