lua-websockets icon indicating copy to clipboard operation
lua-websockets copied to clipboard

lua-websockets can run with lua 5.3?

Open feihuroger opened this issue 9 years ago • 9 comments

I have to build with 5.3, need to change bitopt to bit32, another question is Copas just for lua 5.1, 5.2. websocket.client.copas is error.

feihuroger avatar Oct 29 '15 17:10 feihuroger

By requiring single modules you can circumvent auto require copas. e.g. require('websockets.client_ev')

PRs welcome :+1:

lipp avatar Feb 29 '16 08:02 lipp

copas supports Lua 5.3 since 2.0.1. No PRs needed, at least not for copas :wink:

The module that creates problem seems to be luabitop. It would be great if we can conditionally drop that dependency for Lua > 5.1.

I can take a look at it when I will need 5.3 support, but this will take a couple of months.

ntd avatar Apr 05 '16 12:04 ntd

I just bumped into this issue. I guess I'll subscribe to this thread. Thanks.

RussellHaley avatar Apr 07 '16 06:04 RussellHaley

Hi there, I'm still stuck on this. Can anyone help? I was told 5.3 shouldn't need luabitop?

RussellHaley avatar Sep 06 '16 06:09 RussellHaley

I think for now it does not suppurt bit operations on Lua 5.3. And because there no bit32 module I suggest use bit32 from luarocks. It works fine on Lua 5.3. Or you can make PR to add support this. :)

moteus avatar Sep 06 '16 12:09 moteus

Would replacing bit.lua with this help?

https://github.com/daurnimator/lua-http/blob/master/http/bit.lua

RussellHaley avatar Sep 07 '16 06:09 RussellHaley

You also need shift operations. Checkou my variant. https://github.com/moteus/lua-lluv-websocket/blob/master/src/lluv/websocket/bit.lua

moteus avatar Sep 07 '16 06:09 moteus

I tried to use Lua 5.3 in the x64-Version but failed, too:

  1. I could solve the issue about bit.lua by creating my own (incomplete) file which basically wraps built-in operators from Lua 5.3 into functions:: return { band = function(a, b) return a & b end; bor = function(a, b) return a | b end; bxor = function(a, b) return a ~ b end; bnot = function(x) return ~ x end; lshift = function(x, n) return x << n end; rshift = function(x, n) return x >> n end; arshift = function(x, n) print('arshift missing') return x end; rol = function(x, n) return (x<<(n%64))|(x>>(64-(n%64))) end; ror = function(x, n) return (x>>(n%64))|(x<<(64-(n%64))) end; bswap = function(x) print('bswap missing') return x end; }

  2. However, this is not sufficient : The client of the test-server-copas.lua still reports the error "Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value"

Now I'm looking for different libraries like https://github.com/daurnimator/lua-http

FrankBuchholz avatar Sep 30 '19 12:09 FrankBuchholz

For bitop, there is a fork from https://github.com/LuaDist/luabitop, which support Lua 5.3 (and provide bit.dll etc). (And there is more forks from original luabitop)

But with further test, I get error attempt to call a nil value (global 'unpack') at 'websocket\frame.lua', so means there is old incompatible Lua function. Seems its easy to convert/update.. Replace unpack to table.unpack.

@FrankBuchholz Thank you for introduce https://github.com/daurnimator/lua-http (Dependency doesn't support Microsoft Windows operating systems).

robertlzj avatar Feb 19 '22 18:02 robertlzj