JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.9k stars 386 forks source link

Socket error testing against libmicrohttpd connection refused #226

Open lennyhans opened 11 months ago

lennyhans commented 11 months ago

Hi! first of all, thanks for your work, siege it is really simple and helpful.

Now the situation, I have encounter an error when trying to test a simple httpserver written in C but, when I hit the endpoint (that is accesible from the browser and simple curl) got a socket error. But I can use my local address to test.

I don´t really know where to look at, thanks in advance on any hint!

Setup

Siege

$ siege -V
SIEGE 4.1.7-b5

$ siege -D -g -v http://localhost:8080
[debug] browser.c:914 attempting connection to localhost:8080
[debug] browser.c:929 creating new socket:     localhost:8080
[error] socket: unable to connect sock.c:282: Connection refused
[debug] browser.c:941 connection failed. error 111(Connection refused)

Curl

$ curl -v http://localhost:8080
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.88.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Sat, 09 Sep 2023 02:58:24 GMT
< Content-Length: 90
< 
* Connection #0 to host localhost left intact
<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>

and while searching for shared experiences this link was helpful, because when trying with my local ip address it begin the siege with no problems.

Siege with local ip address (head)

$ siege -g -D http://192.168.1.203:8080/ 
[debug] browser.c:914 attempting connection to 192.168.1.203:8080
[debug] browser.c:929 creating new socket:     192.168.1.203:8080
[debug] browser.c:949 good socket connection:  192.168.1.203:8080
HEAD / HTTP/1.0
Host: 192.168.1.203:8080
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.7-b5
Connection: close

Siege with local ip address (get)

$ siege -p -D http://192.168.1.203:8080/ 
** SIEGE 4.1.7-b5: debugging enabled

Copyright (C) 2023 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

** Preparing 1 concurrent users for battle.
The server is now under siege...
[debug] browser.c:914 attempting connection to 192.168.1.203:8080
[debug] browser.c:929 creating new socket:     192.168.1.203:8080
[debug] browser.c:949 good socket connection:  192.168.1.203:8080
GET / HTTP/1.0
Host: 192.168.1.203:8080
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.7-b5
Connection: close

HTTP/1.1 200 OK
Date: Sat, 09 Sep 2023 03:02:49 GMT
Connection: close
Content-Length: 90

<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>

Transactions:               1    hits
Availability:             100.00 %
Elapsed time:               0.00 secs
Data transferred:           0.00 MB
Response time:              0.00 ms
Transaction rate:           0.00 trans/sec
Throughput:             0.00 MB/sec
Concurrency:                0.00
Successful transactions:        1
HTTP OK received:           1
Failed transactions:            0
Longest transaction:            0.00 ms
Shortest transaction:           0.00 ms
lennyhans commented 11 months ago

Siege with strace

$ strace siege -D -g -v http://localhost:8080
execve("/home/$USER/bin/siege", ["siege", "-D", "-g", "-v", "http://localhost:8080"], 0x7ffc1e8543a0 /* 55 vars */) = 0
brk(NULL)                               = 0x560fcdd8a000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2fa5434000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No existe el fichero o el directorio)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=120246, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 120246, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2fa5416000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=692256, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 690288, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2fa536d000
mmap(0x7f2fa538c000, 380928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f000) = 0x7f2fa538c000
mmap(0x7f2fa53e9000, 126976, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7c000) = 0x7f2fa53e9000
mmap(0x7f2fa5408000, 57344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9b000) = 0x7f2fa5408000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libcrypto.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=4709656, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 4720048, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2fa4e00000
mmap(0x7f2fa4ec5000, 2588672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xc5000) = 0x7f2fa4ec5000
mmap(0x7f2fa513d000, 905216, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x33d000) = 0x7f2fa513d000
mmap(0x7f2fa521a000, 409600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x41a000) = 0x7f2fa521a000
mmap(0x7f2fa527e000, 9648, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2fa527e000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=121280, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 123280, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2fa534e000
mmap(0x7f2fa5351000, 77824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f2fa5351000
mmap(0x7f2fa5364000, 28672, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f2fa5364000
mmap(0x7f2fa536b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7f2fa536b000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220s\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=1922136, ...}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 1970000, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2fa4c1f000
mmap(0x7f2fa4c45000, 1396736, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7f2fa4c45000
mmap(0x7f2fa4d9a000, 339968, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17b000) = 0x7f2fa4d9a000
mmap(0x7f2fa4ded000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ce000) = 0x7f2fa4ded000
mmap(0x7f2fa4df3000, 53072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2fa4df3000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2fa534c000
arch_prctl(ARCH_SET_FS, 0x7f2fa534d040) = 0
set_tid_address(0x7f2fa534d310)         = 766958
set_robust_list(0x7f2fa534d320, 24)     = 0
rseq(0x7f2fa534d960, 0x20, 0, 0x53053053) = 0
mprotect(0x7f2fa4ded000, 16384, PROT_READ) = 0
mprotect(0x7f2fa536b000, 4096, PROT_READ) = 0
mprotect(0x7f2fa521a000, 397312, PROT_READ) = 0
mprotect(0x7f2fa5408000, 40960, PROT_READ) = 0
mprotect(0x560fcdc47000, 8192, PROT_READ) = 0
mprotect(0x7f2fa5466000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f2fa5416000, 120246)          = 0
getrandom("\x35\x03\xaf\x07\xa8\x5e\x23\x11", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x560fcdd8a000
brk(0x560fcddab000)                     = 0x560fcddab000
rt_sigprocmask(SIG_BLOCK, [HUP INT PIPE ALRM TERM], NULL, 8) = 0
newfstatat(AT_FDCWD, "/home/$USER/.siege", {st_mode=S_IFDIR|0750, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "/home/$USER/.siege/siege.conf", {st_mode=S_IFREG|0644, st_size=21246, ...}, 0) = 0
openat(AT_FDCWD, "/home/$USER/.siege/siege.conf", O_RDONLY) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=21246, ...}, AT_EMPTY_PATH) = 0
read(3, "# Updated by Siege %_VERSION%, %"..., 4096) = 4096
read(3, " = ib.adnxs.com\n\n#\n# CSV Verbose"..., 4096) = 4096
read(3, "nd line takes precedent over thi"..., 4096) = 4096
read(3, " let it.  Set this to \n# false f"..., 4096) = 4096
brk(0x560fcddcc000)                     = 0x560fcddcc000
brk(0x560fcddcb000)                     = 0x560fcddcb000
read(3, "\n#\n# ex: login = jdfulmer:topsec"..., 4096) = 4096
read(3, "ogin \n# as long as each one has "..., 4096) = 766
read(3, "", 4096)                       = 0
close(3)                                = 0
futex(0x7f2fa527ddcc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527ddc0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527ddb8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527dec0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527dda8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527dda0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527d824, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527de04, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527d818, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa527ddb0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/usr/lib/ssl/openssl.cnf", O_RDONLY) = 3
futex(0x7f2fa527d8e8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=12332, ...}, AT_EMPTY_PATH) = 0
read(3, "#\n# OpenSSL example configuratio"..., 4096) = 4096
read(3, "he listed attributes must be the"..., 4096) = 4096
read(3, "R hex encoding of an extension: "..., 4096) = 4096
read(3, "\noldcert = $insta::certout # ins"..., 4096) = 44
read(3, "", 4096)                       = 0
close(3)                                = 0
futex(0x7f2fa527dd98, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa5415844, FUTEX_WAKE_PRIVATE, 2147483647) = 0
sysinfo({uptime=1729937, loads=[50336, 51456, 36704], totalram=16378089472, freeram=2472415232, sharedram=3159330816, bufferram=271638528, totalswap=8119119872, freeswap=5693358080, procs=1883, totalhigh=0, freehigh=0, mem_unit=1}) = 0
futex(0x7f2fa5415864, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f2fa5415858, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/home/$USER/.siege/cookies.txt", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "/home/$USER/.siege/cookies.txt", O_RDONLY) = 3
brk(0x560fcddf7000)                     = 0x560fcddf7000
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=242, ...}, AT_EMPTY_PATH) = 0
read(3, "#\n# Siege cookies file. You may "..., 4096) = 242
read(3, "", 4096)                       = 0
close(3)                                = 0
brk(0x560fcdde3000)                     = 0x560fcdde3000
openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 3
read(3, "Z\272\340\223", 4)             = 4
close(3)                                = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f2fa4ca55b0, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f2fa4c5afd0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f2fa441e000
mprotect(0x7f2fa441f000, 8388608, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [HUP INT PIPE ALRM TERM], 8) = 0
clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f2fa4c1e990, parent_tid=0x7f2fa4c1e990, exit_signal=0, stack=0x7f2fa441e000, stack_size=0x7fff80, tls=0x7f2fa4c1e6c0} => {parent_tid=[766959]}, 88) = 766959
rt_sigprocmask(SIG_SETMASK, [HUP INT PIPE ALRM TERM], NULL, 8) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f2fa3c1d000
mprotect(0x7f2fa3c1e000, 8388608, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [HUP INT PIPE ALRM TERM], 8) = 0
clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f2fa441d990, parent_tid=0x7f2fa441d990, exit_signal=0, stack=0x7f2fa3c1d000, stack_size=0x7fff80, tls=0x7f2fa441d6c0} => {parent_tid=[766960]}, 88) = 766960
rt_sigprocmask(SIG_SETMASK, [HUP INT PIPE ALRM TERM], NULL, 8) = 0
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 1823972885
futex(0x560fcddad3b8, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x560fcddad418, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1694228781, tv_nsec=126341000}, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Recurso no disponible temporalmente)
futex(0x560fcddad368, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f2fa4c1e990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 766959, NULL, FUTEX_BITSET_MATCH_ANY[debug] browser.c:914 attempting connection to localhost:8080
[debug] browser.c:929 creating new socket:     localhost:8080
[error] socket: unable to connect sock.c:282: Connection refused
[debug] browser.c:941 connection failed. error 111(Connection refused)
) = 0
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 1823972885
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=10000000}, NULL) = 0
brk(0x560fcddcf000)                     = 0x560fcddcf000
openat(AT_FDCWD, "/home/$USER/.siege/cookies.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=0, ...}, AT_EMPTY_PATH) = 0
write(3, "#\n# Siege cookies file. You may "..., 242) = 242
close(3)                                = 0
futex(0x7f2fa527d5d8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
exit_group(0)                           = ?
+++ exited with 0 +++
matias-gmg commented 8 months ago

Any update on this issue? I am getting [error] socket: unable to connect sock.c:282: Connection refused in macOs after executing the following command: gtimeout 30 siege -c 20 http://localhost:3000/