sctangqiang / skynetpatch Goto Github PK
View Code? Open in Web Editor NEWskynet扩展支持websocket协议的netpack、gate、gateserver
skynet扩展支持websocket协议的netpack、gate、gateserver
对skynet增加websocket的协议处理 使用步骤: 在skynet下建立patch目录,然后将这里的所有文件copy到这个目录 cd patch ./dopatch.sh cd .. 然后就可以按照skynet官网说明来make了. websocket的例子, 使用了agent的例子 ./skynet examples/wsconfig 另一终端运行 ./3rd/lua/lua examples/wsclient.lua
gdb分析core文件:
#0 websocket_strnpos ( haystack=0x7fa692c00000 <Address 0x7fa692c00000 out of bounds>, haystack@entry=0x7fa692914eb0 "G\262P\223\246\177", haystack_length=haystack_length@entry=1, needle_length=4, needle=0x7fa691ffe348 "\r\n\r\n") at lualib-src/lua-websocketnetpack.c:343 #1 0x00007fa691ffddd8 in get_http_header (size=1, buffer=0x7fa692914eb0 "G\262P\223\246\177") at lualib-src/lua-websocketnetpack.c:359 #2 filter_data_ (L=L@entry=0x7fa69223ed08, fd=3105, buffer=buffer@entry=0x7fa692914eb0 "G\262P\223\246\177", size=1, wsocket_handeshake=wsocket_handeshake@entry=1) at lualib-src/lua-websocketnetpack.c:564 #3 0x00007fa691ffe0b6 in filter_data (wsocket_handeshake=1, size=<optimized out>, buffer=0x7fa692914eb0 "G\262P\223\246\177", fd=<optimized out>, L=0x7fa69223ed08) at lualib-src/lua-websocketnetpack.c:641 #4 lfilter (L=0x7fa69223ed08) at lualib-src/lua-websocketnetpack.c:686 #5 0x0000000000414449 in luaD_precall (L=L@entry=0x7fa69223ed08, func=func@entry=0x7fa69289b700, nresults=nresults@entry=-1) at ldo.c:434 #6 0x000000000041f8b6 in luaV_execute (L=L@entry=0x7fa69223ed08) at lvm.c:1162 #7 0x000000000041471f in luaD_call (L=L@entry=0x7fa69223ed08, func=<optimized out>, nResults=<optimized out>) at ldo.c:499 #8 0x0000000000414771 in luaD_callnoyield (L=0x7fa69223ed08, func=<optimized out>, nResults=<optimized out>) at ldo.c:509 #9 0x0000000000413bac in luaD_rawrunprotected (L=L@entry=0x7fa69223ed08, f=f@entry=0x410880 <f_call>, ud=ud@entry=0x7fa6959f5a80) at ldo.c:142 #10 0x0000000000414a3d in luaD_pcall (L=L@entry=0x7fa69223ed08, func=func@entry=0x410880 <f_call>, u=u@entry=0x7fa6959f5a80, old_top=176, ef=<optimized out>) at ldo.c:729 #11 0x0000000000411e9c in lua_pcallk (L=L@entry=0x7fa69223ed08, nargs=5, nresults=nresults@entry=-1, errfunc=errfunc@entry=0, ctx=ctx@entry=0, k=k@entry=0x426d20 <finishpcall>) at lapi.c:969 #12 0x0000000000426eb0 in luaB_pcall (L=0x7fa69223ed08) at lbaselib.c:424 #13 0x0000000000414449 in luaD_precall (L=L@entry=0x7fa69223ed08, func=func@entry=0x7fa69289b590, nresults=nresults@entry=2) at ldo.c:434 #14 0x000000000041fb5e in luaV_execute (L=L@entry=0x7fa69223ed08) at lvm.c:1146 #15 0x000000000041471f in luaD_call (L=L@entry=0x7fa69223ed08, func=<optimized out>, nResults=<optimized out>) at ldo.c:499 #16 0x0000000000414771 in luaD_callnoyield (L=0x7fa69223ed08, func=<optimized out>, nResults=<optimized out>) at ldo.c:509 #17 0x0000000000413bac in luaD_rawrunprotected (L=L@entry=0x7fa69223ed08, f=f@entry=0x410880 <f_call>, ud=ud@entry=0x7fa6959f5d30) at ldo.c:142 #18 0x0000000000414a3d in luaD_pcall (L=L@entry=0x7fa69223ed08, func=func@entry=0x410880 <f_call>, u=u@entry=0x7fa6959f5d30, old_top=48, ef=<optimized out>) at ldo.c:729 #19 0x0000000000411e9c in lua_pcallk (L=L@entry=0x7fa69223ed08, nargs=nargs@entry=5, nresults=nresults@entry=0, errfunc=errfunc@entry=1, ctx=ctx@entry=0, k=k@entry=0x0) at lapi.c:969 #20 0x00007fa693be8299 in _cb (context=0x7fa692a21980, ud=0x7fa69223ed08, type=6, session=0, source=0, msg=0x7fa6928a9ce0, sz=24) at lualib-src/lua-skynet.c:52 #21 0x000000000040a1d5 in dispatch_message (ctx=0x7fa692a21980, msg=0x7fa6959f5e00) at skynet-src/skynet_server.c:274 #22 0x000000000040ad70 in skynet_context_message_dispatch ( sm=sm@entry=0x7fa6986168a0, q=0x7fa692b01b80, q@entry=0x0, weight=weight@entry=-1) at skynet-src/skynet_server.c:334 #23 0x000000000040b49d in thread_worker (p=<optimized out>) at skynet-src/skynet_start.c:162 #24 0x00007fa699547ea5 in start_thread () from /lib64/libpthread.so.0 #25 0x00007fa698b628dd in clone () from /lib64/libc.so.6
例子agent直接给客户端回包用的是socket.write() sproto编码的数据,并没有包一层websocket的协议,但是客户端的c库解包的时候又有按照websocket协议去解包,按理说,这样肯定有问题,但是例子却能正常跑,请问下是什么原因导致这个问题的。
客户端关闭浏览器会发一个websocket close消息过来
长度为2 内容是 status code 1001
这个消息应该放在网关中处理掉 却发送的逻辑层
按照readme给出的方法执行以下代码。
cd ~/github/
git clone https://github.com/skynet
cd skynet
git submodule add https://github.com/sctangqiang/skynetpatch patch
cd patch
sh dopatch.sh
在dopatch执行时报错
cp: target '../skynet/lualib-src' is not a directory
cp: target '../skynet/lualib/snax' is not a directory
cp: target '../skynet/service' is not a directory
cp: target '../skynet/examples' is not a directory
随后检查dopatch.sh代码发现
cp ./lualib-src/*.c ../skynet/lualib-src
cp ./lualib/snax/*.lua ../skynet/lualib/snax
cp ./service/*.lua ../skynet/service
cp ./examples/* ../skynet/examples
如果把仓库克隆到skynet目录下面的话,也就是skynet/patch
,然后cd
进去dopatch
的话是不行的。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.