XMLHtt prequest:网络错误0x2efd,无法完成,由于操作错误00002efd [英] XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd
问题描述
我使用socket.io为Windows Azure项目。奇怪的socket.io服务器启动时,我只是部署Web角色,但是当我部署整个云计算项目中,socket.io服务器犯规开始,我得到这个错误 -
SCRIPT7002:XMLHtt prequest:网络错误0x2efd,无法完成由于错误00002efd操作。
我完全不知道这意味着什么。谁能帮我在这一个?我一直在敲打我的脑袋一下一整天。
SocketClient.html
<脚本>
变种插座= io.connect('http://127.0.0.1:4001');
socket.on('新闻',函数(数据){
的console.log(数据);
});$(函数(){
$(#sendresponse)。绑定(点击,函数(){
socket.emit('服务器','世界您好'); });
}
);
< / SCRIPT>
App.js
VAR应用=要求('前preSS')(),服务器=要求(HTTP)。createServer(APP),IO =要求('socket.io ')。听(服务器);server.listen(4001);app.get('/',函数(REQ,RES){
res.sendfile(__目录名称+/index.html');
});io.sockets.on('连接',函数(插座){
socket.emit('新闻',{打招呼:第一次连接'});
socket.on(服务器,功能(数据){
的console.log(数据);
socket.emit(新闻,你好);
});
});
原来,即我已经把我的web.config中iisnode处理wasnt做App.js脚本不运行时我部署云计算项目,当整个云项目部署了工作。要通过此文章,我发现我后,不得不把一些文件在Web角色即我的bin文件夹 - ChangeConfig.ps1,download.ps1,node.cmd,setup_web.cmd。当你通过这篇文章可以生成这些文件。最后,你必须把这个code在ServiceDefinition.csdef中
<&启动GT;
<任务的命令行=setup_web.cmd和放大器; GT;的log.txt的ExecutionContext =架空>
<环境与GT;
<变量名=模拟>
< RoleInstanceValue的XPath =/ RoleEnvironment /部署/ @效仿/>
< /可变>
<变量名=RUNTIMEIDVALUE =节点; iisnode/>
<变量名=RUNTIMEURLVALUE =/>
< /环境与GT;
< /任务>
< /启动>
和瞧!它的工作原理就像一个魅力。你仍然有通过在浏览器中运行127.0.0.1/App.js启动socket.io服务器。我仍然在寻找如何programattically开始App.js。
I am using socket.io for a windows azure project. Strangely the socket.io server starts when i just deploy the web role but when i deploy the whole cloud project, the socket.io server doesnt start and i get this error -
"SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd."
I have absolutely no idea what that means. Can anyone help me out on this one? I have been banging my head about it all day.
SocketClient.html
<script>
var socket = io.connect('http://127.0.0.1:4001');
socket.on('news', function (data) {
console.log(data);
});
$(function () {
$("#sendresponse").bind("click", function () {
socket.emit('server', 'Hello World');
});
}
);
</script>
App.js
var app = require('express')(), server = require('http').createServer(app), io = require('socket.io').listen(server);
server.listen(4001);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'first time connect' });
socket.on('server', function (data) {
console.log(data);
socket.emit('news',"hello");
});
});
Turned out that the App.js script was not running when i deployed the cloud project, i.e the iisnode handler which i had put in my web.config wasnt doing its job when the whole cloud project was deployed. After going through this article i found out that i had to put some files in my bin folder of web role namely - ChangeConfig.ps1,download.ps1,node.cmd,setup_web.cmd. you can generate these files when you go through that article. And finally you have to put this code in your ServiceDefinition.csdef
<Startup>
<Task commandLine="setup_web.cmd > log.txt" executionContext="elevated">
<Environment>
<Variable name="EMULATED">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
</Variable>
<Variable name="RUNTIMEID" value="node;iisnode" />
<Variable name="RUNTIMEURL" value="" />
</Environment>
</Task>
</Startup>
And voila!! It works like a charm. You would still have to start the socket.io server by running 127.0.0.1/App.js on browser. I am still looking at how to start App.js programattically.
这篇关于XMLHtt prequest:网络错误0x2efd,无法完成,由于操作错误00002efd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!