javascript - Socket.io packets get lost between dis- and reconnect -


i using socket.io connecting smartphone (in webframe) server , sending few messages around (a few short strings per minute, nothing big). since smartphones tend have unsteady connection, socket.io forced reconnect every , then. automatically , messages want send after noticed connection unavailable buffered , sent bundle once connection reestablished. it's going socket.io.

but when send message right before socket.io notices connection gone, message lost. can not transmitted, not buffered socket.io, either. quite content socket.io, problem bugging me, since not send many messages, need send sent reliably. while connection established, messages transmitted perfectly, not need check that. second between connection loss , socket.io noticing critical moment face packet loss.

i have been thinking mimicking tcp behaviour sequence numbers , acks feels bit shooting ants rocket launcher. question is: have lightweight solution problem or encountered himself? not ask explicit code - can myself - concept or rid of specific problem great.

thanks in advance!

why don't log every message database? , use socket.io acknowledge option make better.

from http://socket.io/#how-to-use server

var io = require('socket.io').listen(80);  io.sockets.on('connection', function (socket) {   socket.on('ferret', function (name, fn) {     fn('woot');   }); }); 

client

<script>   var socket = io.connect(); // tip: .connect no args auto-discovery   socket.on('connect', function () { // tip: can avoid listening on `connect` , listen on events directly too!     socket.emit('ferret', 'tobi', function (data) {       console.log(data); // data 'woot'     });   }); </script> 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -