1

运行简单的 HTTP 请求:

(dex:get "http://localhost:8000/wp-json/wp/v2/posts")

失败并出现错误(dex堆栈跟踪)

Condition USOCKET:CONNECTION-REFUSED-ERROR was signalled.
   [Condition of type USOCKET:CONNECTION-REFUSED-ERROR]

Backtrace:
  0: (USOCKET::HANDLE-CONDITION #<SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR {1008622AF3}> #<USOCKET:STREAM-USOCKET {1008622583}>)
  1: (SB-KERNEL::%SIGNAL #<SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR {1008622AF3}>)
  2: (ERROR SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR :ERRNO 61 :SYSCALL "connect")
  3: (SB-BSD-SOCKETS:SOCKET-ERROR "connect" 61)
  4: (SB-BSD-SOCKETS::CALL-WITH-SOCKET-ADDR #<SB-BSD-SOCKETS:INET-SOCKET 127.0.0.1:59367, fd: 17 {1008622473}> (#(127 0 0 1) 8000) #<CLOSURE (FLET SB-BSD-SOCKETS::WITH-SOCKET-ADDR-THUNK :IN SB-BSD-SOCKETS:..
  5: ((:METHOD SB-BSD-SOCKETS:SOCKET-CONNECT (SB-BSD-SOCKETS:SOCKET)) #<SB-BSD-SOCKETS:INET-SOCKET 127.0.0.1:59367, fd: 17 {1008622473}> #(127 0 0 1) 8000) [fast-method]
  6: ((FLET "WITHOUT-INTERRUPTS-BODY-22" :IN USOCKET:SOCKET-CONNECT))
  7: (USOCKET:SOCKET-CONNECT "localhost" 8000 :PROTOCOL :STREAM :ELEMENT-TYPE (UNSIGNED-BYTE 8) :TIMEOUT 10 :DEADLINE NIL :NODELAY T :LOCAL-HOST NIL :LOCAL-PORT NIL)
  8: ((LABELS DEXADOR.BACKEND.USOCKET::MAKE-NEW-CONNECTION :IN DEXADOR.BACKEND.USOCKET:REQUEST) #<QURI.URI.HTTP:URI-HTTP http://localhost:8000/wp-json/wp/v2/posts
  9: (DEXADOR.BACKEND.USOCKET:REQUEST #<unavailable argument> :METHOD :GET)
 10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEXADOR:GET "http://localhost:8000/wp-json/wp/v2/posts") #<NULL-LEXEN..
 11: (EVAL (DEXADOR:GET "http://localhost:8000/wp-json/wp/v2/posts"))

或(drakma堆栈跟踪)

Condition USOCKET:CONNECTION-REFUSED-ERROR was signalled.
   [Condition of type USOCKET:CONNECTION-REFUSED-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1003CE8413}>)

Backtrace:
  0: (USOCKET::HANDLE-CONDITION #<SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR {1005657693}> #<USOCKET:STREAM-USOCKET {1005657123}>)
  1: (SB-KERNEL::%SIGNAL #<SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR {1005657693}>)
  2: (ERROR SB-BSD-SOCKETS:CONNECTION-REFUSED-ERROR :ERRNO 61 :SYSCALL "connect")
  3: (SB-BSD-SOCKETS:SOCKET-ERROR "connect" 61)
  4: (SB-BSD-SOCKETS::CALL-WITH-SOCKET-ADDR #<SB-BSD-SOCKETS:INET-SOCKET 127.0.0.1:59799, fd: 12 {1005657013}> (#(127 0 0 1) 8000) #<CLOSURE (FLET SB-BSD-SOCKETS::WITH-SOCKET-ADDR-THUNK :IN SB-BSD-SOCKETS:..
  5: ((:METHOD SB-BSD-SOCKETS:SOCKET-CONNECT (SB-BSD-SOCKETS:SOCKET)) #<SB-BSD-SOCKETS:INET-SOCKET 127.0.0.1:59799, fd: 12 {1005657013}> #(127 0 0 1) 8000) [fast-method]
  6: ((FLET "WITHOUT-INTERRUPTS-BODY-22" :IN USOCKET:SOCKET-CONNECT))
  7: (USOCKET:SOCKET-CONNECT "localhost" 8000 :PROTOCOL :STREAM :ELEMENT-TYPE FLEXI-STREAMS:OCTET :TIMEOUT 20 :DEADLINE NIL :NODELAY :IF-SUPPORTED :LOCAL-HOST NIL :LOCAL-PORT NIL)
  8: (DRAKMA:HTTP-REQUEST #<PURI:URI http://localhost:8000/wp-json/wp/v2/posts>)
  9: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DRAKMA:HTTP-REQUEST "http://localhost:8000/wp-json/wp/v2/posts") #<NULL-LEXENV>)
 10: (EVAL (DRAKMA:HTTP-REQUEST "http://localhost:8000/wp-json/wp/v2/posts"))
 11: (SWANK::EVAL-REGION "(drakma:http-request \"http://localhost:8000/wp-json/wp/v2/posts\") ..)
 12: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
 13: (SWANK-REPL::TRACK-PACKAGE #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {10056566CB}>)
 14: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100565666B}>)
 15: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100565664B}>)
 16: (SWANK-REPL::REPL-EVAL "(drakma:http-request \"http://localhost:8000/wp-json/wp/v2/posts\") ..)
 17: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK-REPL:LISTENER-EVAL "(drakma:http-request \"http://localhost:8000/wp-json/wp/v2/posts\") ..)
 18: (EVAL (SWANK-REPL:LISTENER-EVAL "(drakma:http-request \"http://localhost:8000/wp-json/wp/v2/posts\") ..)
 19: (SWANK:EVAL-FOR-EMACS (SWANK-REPL:LISTENER-EVAL "(drakma:http-request \"http://localhost:8000/wp-json/wp/v2/posts\") ..)
 20: (SWANK::PROCESS-REQUESTS NIL)
 21: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 22: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 23: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {1003CF008B}>)
 24: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/Users/ihar/quicklisp/dists/quicklisp/software/slime-v2.22/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK::HA..
 25: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #1=#<SWANK/GRAY::SLIME-INPUT-STREAM {1003BEA693}>) (*STANDARD-OUTPUT* . #2=#<SWANK/GRAY::SLIME-OUTPUT-STREAM {1003CC8CF3}>) (*TRACE-OUTPUT* . #2#) (*ERR..
 26: (SWANK::HANDLE-REQUESTS #<SWANK::MULTITHREADED-CONNECTION {10032427F3}> NIL)
 27: ((FLET SB-UNIX::BODY :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 28: ((FLET "WITHOUT-INTERRUPTS-BODY-4" :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 29: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 30: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-THREAD::CALL-WITH-MUTEX))
 31: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE) {3A67D6B}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THREAD "..
 32: (SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE #<SB-THREAD:THREAD "repl-thread" RUNNING {1003CE8413}> NIL #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::SPAWN-REPL-THREAD) {1003CE83BB}> NIL)
 33: ("foreign function: call_into_lisp")
 34: ("foreign function: new_thread_trampoline")
 35: ("foreign function: _pthread_body")
 36: ("foreign function: _pthread_body")
 37: ("foreign function: thread_start")

在Clozure Common Lisp 版本 1.11.5 (DarwinX8664)上运行相同的请求效果很好。

有人知道原因吗?

4

1 回答 1

0

我遇到了同样的情况,我注意到 Drakma 试图访问的本地服务是基于 ipv6 的,所以他们在 ::1 上侦听,当我将这些服务设置为显式地在 127.0.0.1:xxxx 而不是 localhost:xxxx 上侦听时,它们变成了 ipv4 Drakma 没有再抱怨了。

于 2019-02-21T17:28:43.063 回答