【发布时间】:2019-01-03 08:45:14
【问题描述】:
我导入了 git socket.io 聊天室项目!该代码与http = require ('http') 正常工作,但在交换https = require ('https') 时,我的服务器响应错误500 http
var express = require('express')
, app = express()
// , http = require('http')
, https = require('https')
, fs = require('fs')
, privateKey = fs.readFileSync('HTTPS_Permissions/key.key', 'utf8')
, certificate = fs.readFileSync('HTTPS_Permissions/cert.cert', 'utf8')
, credentials = {key: privateKey, cert: certificate}
, httpsServer = https.createServer(credentials, app)
// , httpServer = http.createServer(app)
, io = require('socket.io').listen(httpsServer)
//, port = process.env.PORT || 8080
, port = process.env.PORT
httpsServer.listen(port, function () {
console.log('Server listening on port %d', port);
});
//httpServer.listen(port);
// routing
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
【问题讨论】:
-
这里的例子,对吧? github.com/socketio/chat-example
-
@JayGong 在 azure 门户中导入了这个 git --> github.com/fern4lvarez/socketiochatrooms
-
项目在本地能正常运行吗?您是否检查过错误是否由项目本身引起,而不是来自天蓝色?您尝试了哪些操作?
-
@JayGong 是的,本地工作 100%,天蓝色的新手...我搁置 https,我现在正在测试 http,服务器上出现 404 错误。我的项目位于“公共”文件夹和“wwwroot”文件夹中的“应用程序节点”中,我无法连接,它给了我错误 404。如果我分配虚拟路径目录“socket.io”e 目录天蓝色门户中的物理路径“site\wwwroot\socket.io”,返回错误 403。如何在子文件夹中运行站点以及根文件夹中的节点/socket.io?
-
@JayGong 这个例子我的目录结构 --> i.imgur.com/w46czXG.png