lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Sync receive check - masked or unmasked? #93

Closed EnTerr closed 8 years ago

EnTerr commented 8 years ago

I am confused about this bit of code

    if not self.is_server and masked then
      return clean(false,1006,'Websocket receive failed: frame was not masked')
    end

in https://github.com/lipp/lua-websockets/blob/master/src/websocket/sync.lua#L31

It says that receive have failed because frame was NOT masked - but it actually checks something else, it checks that this receive() was in a client (not a server) and WAS masked?!

lipp commented 8 years ago

Indeed. Thanks. The error message is just wrong. Anyhow, clients must send masked frames and the server must send unmasked.

EnTerr commented 8 years ago

Oh okay. So there is a mandate for the server side too (to not mask), did not know that. But the message was wrong, hence the confusion.

In my case i ran into this as side effect of #94, where client was reading 1 byte too many and consequent frames start getting decoded wrong and eventually will assert-fail at this