node.js - Socket.IO - Message sent from client is failing on server and client -
i working on realtime data communication platform uses socket.io connect server client. server running node.js, , client desktop application in form of webpage using atom's electron.
i receiving messages on client well, when try , send message, through format:
window.socket.emit('embed',{'...'});
the server triggers error handler:
socket.on('error',function(err) { console.log('client error: '+json.stringify(err)); });
i see in log:
client error: {}
debugging socket.io on client side reveals logs when message sent:
[14184:0511/184052:info:console(1)] "socket.io-client:manager writing packet %j +10s", source: https://cdn.socket.io/socket.io-1.3.5.js (1) [14184:0511/184052:info:console(1)] "socket.io-parser encoding packet %j +819ms", source: https://cdn.socket.io/socket.io-1.3.5.js (1) [14184:0511/184052:info:console(1)] "socket.io-parser encoded %j %s +0ms", source: https://cdn.socket.io/socket.io-1.3.5.js (1) [14184:0511/184052:info:console(2)] "%cengine.io-client:socket %cflushing %d packets in socket%c +820ms", source: https://cdn.socket.io/socket.io-1.3.5.js (2)
any clues why might occuring?
edit:
both client , server running socket.io version 1.3.5.
also, attempting log error object using console.log results in line in console:
[typeerror: property 'undefined' of object #<object> not function]
i assume that function bound error event on server not designed accept error object.
edit:
server side, code executed begin socket.io connection.
var io = require('socket.io')(1415); io.on('connection',function(socket) { console.log('connection'); socket.on('error',function(err) { console.log('client error: '+json.stringify(err)); console.log(err); }); socket.on('embed',function(obj) { var type = obj.type; var id = obj.id; console.log('--------------------------------------------'); // ... // additional application logic }); });
client side, code run:
window.socket = io('http://localhost:1415'); // when message emitted, code run. code run on delay, , after messages have been received, assume connection established function(id) { var type = gettype(id); window.socket.emit('embed',{id:id,type:type}); }();
edit (again):
other messages can sent , received successfully.
inspecting raw network data through web inspector network panel reveals this:
Comments
Post a Comment