我终于可以将我的应用程序部署到Azure,但是我总是得到这个与socket.io错误无法加载资源:服务器的状态为404(未找到)socket.io/?EIO=3&transport=polling&t=1503062449710-0
/socket.io/?EIO=3&transport=polling&t=1503062449710-0 Failed to load resource: the server responded with a status of 404 (Not Found)
即使它在我的本地主机上工作。
服务器端:
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(80);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
客户端(浏览次数index.html):
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://chattranslatortwo.azurewebsites.net/');
socket.on('news', function(data) {
console.log(data);
socket.emit('my other event', {
my: 'data'
});
});
</script>
</head>
<body>
</body>
</html>
现在我已经做了很多事情来试图解决这个问题。
1)由于很多帖子都说要将socket.io
更改为socket.io-client
或"https://cdn.socket.io/socket.io-1.3.7.js"
,这对我来说没有任何改变,结果相同。
2)我试过重新安装我的node.js
和socket.io
,但不确定是否改变了任何东西。
3)中启用确信,我的连接是正确的网站应用程序设置
4)我的Azure的网络套接字。
我总是回到同样的错误消息唱出socket.io:
/socket.io/?EIO=3&transport=polling&t=1503062449710-0 Failed to load resource: the server responded with a status of 404 (Not Found)
要么我完全失去了一些东西,或者它似乎插座上工作WebServices
不是从localhost
完全不同。
我一直在解决这个问题很长一段时间了。