i've got this error requests.
The red coloured Request getting Error - 400 Bad request and it taking more then 30sec .After the error the socket work fine but it taking more time for response
In app.js the code is follows
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);
});
});
In client side code
<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>
Please help
Try specifying the full URL as
<script src='http://localhost:3000/socket.io/socket.io.js'>
and in socket
var
= io.connect('http://localhost:3000/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With