Skip to content
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

接受数据超时? #2

Closed
fankeke opened this issue Oct 26, 2017 · 7 comments
Closed

接受数据超时? #2

fankeke opened this issue Oct 26, 2017 · 7 comments

Comments

@fankeke
Copy link

fankeke commented Oct 26, 2017

你好,socks握手、连接过程都是OK的,也获取到了addr,port(正确的),

但在 pipe时,upsocks:receive/downsock:receive老是超时,我超时时间设置为5s钟)

请问有测试过数据传输吗?(不只是握手、连接成功)。

@detailyang
Copy link
Owner

Hello。
这个需要依赖底层的 ngx-lua-stream 实现了 tcpsock:receive('*b') 功能,以便在有数据时立刻唤醒 lua 协程,请确认已经打了补丁openresty/stream-lua-nginx-module#33

@zhu327
Copy link

zhu327 commented Nov 10, 2017

请问如何在现有的openrresty上增加tcpsock:receive('*b')支持?

@detailyang
Copy link
Owner

Hello.
如果你非要尝试在 OpenResty 上实现 SOCKS5 协议,我建议你尝试打patch到自己的源码中 (https://github.com/openresty/stream-lua-nginx-module/pull/33/files)[https://github.com/openresty/stream-lua-nginx-module/pull/33/files], 核心代码就一点,有兴趣的话可以自己试试.

@zhu327
Copy link

zhu327 commented Nov 10, 2017

其实我在写OpenResty版的Shadowsocks, 在openresty-1.13.6.1rc1版本上打上了你的补丁, 跑是跑起来的, 但是会core dump

@detailyang
Copy link
Owner

Hello。
我建议你自己尝试下调试下 core 文件的上下文,或者你可以把core文件的上下文挂gdb上放这里看看,通常是底层的C实现存在问题。

@zhu327
Copy link

zhu327 commented Nov 10, 2017

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/openresty/nginx/sbin/nginx...done.
[New LWP 6071]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by nginx: worker process '. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f83ed16eab6 in lj_alloc_free (msp=0x41d90010, ptr=0xaa0a8141da1820) at lj_alloc.c:1376 1376 lj_alloc.c: 没有那个文件或目录. (gdb) backtrace full #0 0x00007f83ed16eab6 in lj_alloc_free (msp=0x41d90010, ptr=0xaa0a8141da1820) at lj_alloc.c:1376 F = 0x5cc00100008 XP = 0xe417f7c65fc09347 R = 0xaa0a8141da1820 #1 0x00007f83ed11798d in gc_sweep (g=g@entry=0x41d903b8, p=0x41da7090, lim=4294967294, lim@entry=4294967295) at lj_gc.c:406 ow = 33 o = 0x4083ef00 __PRETTY_FUNCTION__ = "gc_sweep" #2 0x00007f83ed118c00 in gc_onestep (L=L@entry=0x40837088) at lj_gc.c:628 old = 228352 g = 0x41d903b8 __PRETTY_FUNCTION__ = "gc_onestep" #3 0x00007f83ed11922c in lj_gc_step (L=0x40837088) at lj_gc.c:689 g = 0x41d903b8 lim = 1640 ostate = -2 #4 0x00007f83ed1276ca in lua_pushlstring (L=0x40837088, str=str@entry=0x7ffdf5038b68 "\027\003\003\001\230", len=413) at lj_api.c:639 s = <optimized out> #5 0x00007f83ed16f603 in emptybuffer (B=B@entry=0x7ffdf5038b50) at lib_aux.c:188 l = <optimized out> #6 0x00007f83ed16fcb9 in luaL_pushresult (B=B@entry=0x7ffdf5038b50) at lib_aux.c:232 No locals. #7 0x0000000000537ed5 in ngx_stream_lua_socket_push_input_data (u=u@entry=0x40838ef0, L=L@entry=0x40837088, ctx=0x171c500, r=0x1727b30) at ../ngx_stream_lua-0.0.3/src/ngx_stream_lua_socket_tcp.c:5092 cl = 0x0 ll = 0x0 chunk_size = <optimized out> b = <optimized out> nbufs = 1 luabuf = { p = 0x7ffdf5038d05 "\vH?\362\374y\214)\363\356ϴ\346\366\204S+\r\277}z\032\373T\002\220\"Z|R\344\351(鴡͵\327\017/\255\276\235\023\320\033H\207U\245\f\360Yo\210\365\252Õ\026}͑\304\312\361cA7a6\037\033\241'p\377*\b\337\034w5~6[\024r\031WquN\a\243\253\305\340\n\036\314\341O\326\f\344\036\256|\002\236l0\033\357\005t\333\344\024\017\344l{\017\373\304\346XLql(k\216B~\252\243m\t^@\260\276\345\352\313(\251=A\037\325\373!4\350\215\375o,\006\237$ZP\336\356\026Ԏ}\253\311\365\004\226r\343\366(\226\070\372Tt83/8\032%N\020\002\276F"..., lvl = 0, L = 0x40837088,
buffer = "\027\003\003\001\230\000\000\000\000\000\000\000\033ԍ\255\233_7\020=\200\236LQR=\277\251\326eu\003\027\265E\365\320\vEަX\207tH\234\307jZ\222*\331\000$\276\333C\317#\326\017\201\346Ep\335so\260\336\024\343\260\nN\006\375X\211^\316\023\207\061\232\374]_V-/Ϗ\222}\353\345\070vjD\230\214\320\366|S\215Ś9\213\a\253\251\252Q\262}\347\245&Y\234\005\065\350Qb7d\360TB\301\247ф\336c\353\311\305! b?E\232ڄI\343*\230\303倔:\236\306\030\200O\236g\232\336'\236\377f. \357|\244\312x\243\333\177\";Wp\373\342\204F\211\032\216\035#\371(\372\243\311\a\263\024+"...}
#8 0x000000000053b12a in ngx_stream_lua_socket_tcp_receive_retval_handler (r=0x1727b30,
u=0x40838ef0, L=0x40837088) at ../ngx_stream_lua-0.0.3/src/ngx_stream_lua_socket_tcp.c:2620
n =
rc =
ctx = 0x171c500
ev =
llcf =
#9 0x0000000000538045 in ngx_stream_lua_socket_tcp_resume_helper (r=0x1727b30,
socket_op=) at ../ngx_stream_lua-0.0.3/src/ngx_stream_lua_socket_tcp.c:5315
---Type to continue, or q to quit---
nret =
rc =
nreqs =
c =
ctx = 0x171c500
coctx =
prepare_retvals = 0x53aff0 <ngx_stream_lua_socket_tcp_receive_retval_handler>
u = 0x40838ef0
#10 0x000000000053de14 in ngx_stream_lua_socket_handle_read_success (u=0x40838ef0, r=0x1727b30)
at ../ngx_stream_lua-0.0.3/src/ngx_stream_lua_socket_tcp.c:3167
ctx =
coctx =
#11 ngx_stream_lua_socket_tcp_read (r=0x1727b30, u=0x40838ef0)
at ../ngx_stream_lua-0.0.3/src/ngx_stream_lua_socket_tcp.c:2192
rc =
c = 0x7f83edbc2498
rev = 0x1728a90
size =
n =
read = 1
#12 0x0000000000449a89 in ngx_epoll_process_events (cycle=0x1716d30, timer=,
flags=) at src/event/modules/ngx_epoll_module.c:902
events =
revents = 5
instance =
i = 0
level =
err =
rev = 0x1728a90
wev =
queue =
c = 0x7f83edbc2498
#13 0x000000000043f80c in ngx_process_events_and_timers (cycle=cycle@entry=0x1716d30)
at src/event/ngx_event.c:252
flags = 1
timer = 9661
delta = 1510308969649
q =
ev =
#14 0x0000000000447475 in ngx_worker_process_cycle (cycle=cycle@entry=0x1716d30,
data=data@entry=0x0) at src/os/unix/ngx_process_cycle.c:815
worker = 0
#15 0x0000000000445f20 in ngx_spawn_process (cycle=cycle@entry=0x1716d30,
proc=proc@entry=0x447430 <ngx_worker_process_cycle>, data=data@entry=0x0,
name=name@entry=0x5491a8 "worker process", respawn=respawn@entry=-3)
at src/os/unix/ngx_process.c:198
on = 1
pid = 0
s = 0
#16 0x0000000000447804 in ngx_start_worker_processes (cycle=cycle@entry=0x1716d30, n=1,
type=type@entry=-3) at src/os/unix/ngx_process_cycle.c:396
i = 0
ch = {command = 1, pid = 0, slot = 0, fd = 0}
#17 0x00000000004485cf in ngx_master_process_cycle (cycle=cycle@entry=0x1716d30)
---Type to continue, or q to quit---
at src/os/unix/ngx_process_cycle.c:135
title = 0x1725e28 "master process nginx -p /home/zhu327/Study/shadowsocks-OR -c nginx.conf"
p =
size =
i =
n =
sigio =
set = {__val = {0 <repeats 16 times>}}
itv = {it_interval = {tv_sec = 24272212, tv_usec = 0}, it_value = {tv_sec = 0, tv_usec = 0}}
live =
delay =
ls =
ccf = 0x1718ae0
#18 0x000000000041ea22 in main (argc=, argv=) at src/core/nginx.c:381
b =
log = 0x7b2ae0 <ngx_log>
i =
cycle = 0x1716d30
init_cycle = {conf_ctx = 0x0, pool = 0x1715970, log = 0x7b2ae0 <ngx_log>, new_log = {
log_level = 0, file = 0x0, connection = 0, disk_full_time = 0, handler = 0x0,
data = 0x0, writer = 0x0, wdata = 0x0, action = 0x0, next = 0x0}, log_use_stderr = 0,
files = 0x0, free_connections = 0x0, free_connection_n = 0, modules = 0x0, modules_n = 0,
modules_used = 0, reusable_connections_queue = {prev = 0x0, next = 0x0},
reusable_connections_n = 0, listening = {elts = 0x0, nelts = 0, size = 0, nalloc = 0,
pool = 0x0}, paths = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0},
config_dump = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0},
config_dump_rbtree = {root = 0x0, sentinel = 0x0, insert = 0x0}, config_dump_sentinel = {
key = 0, left = 0x0, right = 0x0, parent = 0x0, color = 0 '\000', data = 0 '\000'},
open_files = {last = 0x0, part = {elts = 0x0, nelts = 0, next = 0x0}, size = 0,
nalloc = 0, pool = 0x0}, shared_memory = {last = 0x0, part = {elts = 0x0, nelts = 0,
next = 0x0}, size = 0, nalloc = 0, pool = 0x0}, connection_n = 0, files_n = 0,
connections = 0x0, read_events = 0x0, write_events = 0x0, old_cycle = 0x0, conf_file = {
len = 44, data = 0x17159e2 "q\001"}, conf_param = {len = 0, data = 0x0}, conf_prefix = {
len = 34, data = 0x17159e2 "q\001"}, prefix = {len = 34, data = 0x17159c0 ""},
lock_file = {len = 0, data = 0x0}, hostname = {len = 0, data = 0x0},
intercept_error_log_handler = 0x0, intercept_error_log_data = 0x0, entered_logger = 0}
cd =
ccf =

@578141611
Copy link

大哥能不能把打patch的那个文件发出来,我等没有接触过的openresty想要快速试错一下。

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

No branches or pull requests

4 participants