Skip to content

Message data missing or overlaps previous data #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
falsecz opened this issue Sep 14, 2015 · 7 comments
Closed

Message data missing or overlaps previous data #177

falsecz opened this issue Sep 14, 2015 · 7 comments

Comments

@falsecz
Copy link

falsecz commented Sep 14, 2015

start emmiting multiple messages immediately after socket connected
results to message data loss or overlap

emitting multiple messages in short time interval
for eg: (message name, data)

short shortdata
long long
short shortdata
long long

in some cases data are invalid decoded

short shortdata
long long
short shortdata
long shortdata <--- invalid

needs to reproduces:

  • real iOS device
  • enable network link conditioner, for eg. Dsl or worse
  • try multiple time, or try tune setInterval delay or increase cnt

backend

var app = require('http').createServer()

app.listen(8900)

io = require('socket.io')(app)
var x = 0;
var r = []
for(var i = 0; i < 3072; i++) {
    r.push(80)
}

io.sockets.on("connection", function(socket) {
    console.log("ccccc", r.length)
    var cnt = 0
    var t = setInterval(function(){

        socket.emit("shortm", new Buffer("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"));
        socket.emit("longm", new Buffer(r));
        if(cnt++ > 8) {
            clearInterval(t)
        }

    }, 20)
})

ios

    let socket = SocketIOClient(socketURL: "10.0.0.6:8900", opts:["log": false])
    ...
    self.socket.onAny { (e) -> Void in
        dispatch_async(dispatch_get_main_queue()) {
            if(e.event == "connect") {
                return
            }
            let d = e.items![0] as! NSData

            if(e.event != "shortm" && e.event != "longm") {
                fatalError("invalid event");
            }

            if(e.event == "shortm" && d.length != 31) {
                fatalError("invalid short message length \(d.length)")
            }
            if(e.event == "longm" && d.length != 3072) {
                fatalError("invalid long message length \(d.length)")
            }
        }

    }
    self.socket.connect()

there is socket.io log https://gist.github.com/falsecz/4a78d945ffa8c9ceb275
as you can see on line 73, there is long message header followed by short message header, but long data is missing

@nuclearace
Copy link
Member

Well first off, I seem to be having trouble with node.js 4.0.0 and buffers

@nuclearace
Copy link
Member

Yeah with node.js 4.0.0 and socket.io sending Buffers seems to be broken.

@falsecz
Copy link
Author

falsecz commented Sep 14, 2015

sorry I've forgotten append versions info

nodejs v0.12.7
npm socket.io 1.3.6

socket.ui-client-swift v2.4.5
XCode 6.4

@nuclearace
Copy link
Member

Okay, I fixed my 4.0.0 issue. We need to update the engine version in socket.io to the latest

@nuclearace
Copy link
Member

Okay, from what I'm seeing so far, it's a problem when the client is switching from polling to websockets. Doesn't seem to happen when using polling or websockets only

@nuclearace
Copy link
Member

Should be fixed in the latest version. Although the latest version will require Swift 2 and Xcode 7, which should be coming out in 2 days

@falsecz
Copy link
Author

falsecz commented Sep 15, 2015

It works, Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants