Closed eminden closed 9 years ago
Hi, @eminden!
Well, do you have a lua redis module installed (https://github.com/openresty/lua-resty-redis) ? And redis server btw?
Do you use openresty or nginx+lua_nginx module?
Setup is on Ubuntu trusty, redis-server is installed and configured to enable the unix socket. And the latest openresty, this was the file i have used ngx_openresty-1.7.4.1.tar.gz and configured with options --with-pcre-jit --with-debug. I am assuming openresty is having all the lua requirements.
Here is the config under server section of nginx conf, location /ws/ { lua_socket_log_errors off; lua_check_client_abort on;
# This is needed to set additional websocket protocol headers
header_filter_by_lua_file /usr/local/openresty/wiola/headers.lua;
# Set a handler for connection
content_by_lua_file /usr/local/openresty/wiola/handler.lua;
}
And the files for wiola,
/usr/local/openresty/wiola: total 48 drwxr-xr-x 3 root root 4096 Dec 6 22:07 . drwxr-xr-x 8 root root 4096 Dec 6 23:26 .. drwxr-xr-x 2 root root 4096 Dec 5 14:21 debug -rw-r--r-- 1 root root 2875 Dec 5 18:50 handler.lua -rw-r--r-- 1 root root 645 Dec 5 14:19 headers.lua -rw-r--r-- 1 root root 681 Dec 5 17:03 post-handler.lua -rw-r--r-- 1 root root 21653 Dec 5 14:19 wiola.lua
/usr/local/openresty/wiola/debug: total 12 drwxr-xr-x 2 root root 4096 Dec 5 14:21 . drwxr-xr-x 3 root root 4096 Dec 6 22:07 .. -rw-r--r-- 1 root root 924 Dec 5 14:21 var_dump.lua
Hmmm... Do you really have a redis socket at /tmp/redis.sock as it is specified in handler.lua#21 local redisOk, redisErr = wampServer.setupRedis("unix:/tmp/redis.sock") ?
it is correct , i can see some entries in redis as below,
127.0.0.1:6379> keys * 1) "wiRealmrealm1Subsystem.monitor.updateSessions" 2) "wiSes6086559991278" 3) "wiSes6086559991278RevSubs" 4) "wiRealmrealm1Subclient.messageSessions" 5) "wiolaIds" 6) "wiSes6086559991278Subs" 7) "wiolaRealms" 8) "wiRealmrealm1Sessions" 9) "wiRealmrealm1Subs"
I got these keys just after flushing the db and refreshing the wampy test page, at this first attempt wampy connected successfully. But the problem begins when I am loading the same wampy test page from another browser tab, it is getting disconnected with the following console logs, and the nginx logs on the first post.
[wampy] websocket connected [wampy] websocket disconnected
By the way, wampy version is 'v1.0.4' and wiola is on dev branch.
very interesting... I don't have any thoughts... Can you paste your full nginx config and test page. I'll try to check that all in my env. May be i'll find something...
have a look at https://gist.github.com/eminden/1ae9681498e7f0333909
Hi, @eminden! I've spend hours to figure out, what is wrong. And yes, you were right, there is a bug in wiola. I've just fixed it out. Please, try again with latest dev branch version. I think, now everything should work as expected. Also, please notice, that there are some changes in handler.lua (actually added one line).
Thanks @KSDaemon , I had to change a line on wiola.lua
from local subId = tonumber(_M.redis:hget("wiSes" .. v .. "Subs", topic)) to local subId = tonumber(self.redis:hget("wiSes" .. v .. "Subs", topic))
I will keep testing.
ups. I mised that. Thanks! Also committed that to dev. I think, this issue is closed. If you find any bugs — just open new :)
I have tried to setup wiola with wampy on client side, but had some blocking problems i guess, there are lua socket read timeout lines in debug logs and the following runtime error on each client connects.
Any idea, whats wrong?
2014/12/06 23:28:03 [debug] 10952#0: 3 [lua] handler.lua:19: Created websocket 2014/12/06 23:28:03 [debug] 10952#0: 3 lua resume returned 2 2014/12/06 23:28:03 [error] 10952#0: *3 lua entry thread aborted: runtime error: /usr/local/openresty/wiola/wiola.lua:106: bad request stack traceback: coroutine 0: [C]: in function 'connect' /usr/local/openresty/wiola/wiola.lua:106: in function 'setupRedis' /usr/local/openresty/wiola/handler.lua:22: in function </usr/local/openresty/wiola/handler.lua:1>, client: IP, server: SERVER, request: "GET /ws/ HTTP/1.1", host: "HOST"