4
我有這個錯誤請求。socket.io和node.js 400錯誤的請求
的紅色請求得到錯誤 - 400錯誤的請求,並採取更多的則30秒。經過錯誤的插座做工精細,但它花費更多的時間進行響應
在app.js代碼是如下
var app = express(),
server = require('http').createServer(app);
//io = require('socket.io').listen(server);
var sockets = require('socket.io')({
'transports': ['websocket', 'flashsocket','htmlfile','xhr-polling','jsonp-polling']
});
var io = sockets.listen(server,{ resource: '/socket.io/','sync disconnect on unload':true });
io.sockets.on('connection', function(socket){
socket.emit('server_emit');
socket.on('search', function(cattype,pagNo,lang,film,iteamcat,starname){
var query={'ProductType':cattype,'Language':lang,'ProductCategory':iteamcat,'UsedBy':starname,'UsedIn':film},
field={},
options={};
db.collection("Product").find(query,field,options).toArray(function(error, Product2){
socket.emit('result',Product2);
});
});
在客戶端代碼
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect();
socket.on('server_emit', function(){
console.log("Server emitted to Browser")
});
</script>
請幫助
這裏是連接網址? – Ravi 2014-09-13 09:11:21
對不起,我錯過了這個問題 – Sreejith 2014-09-15 05:18:25