Networking 与Aleph的异步响应是';未通过IPv4接收,但与IPv6一起接收

Networking 与Aleph的异步响应是';未通过IPv4接收,但与IPv6一起接收,networking,clojure,ip,compojure,aleph,Networking,Clojure,Ip,Compojure,Aleph,我正在尝试在中设置服务器发送事件,但它无法在IPv4上工作。如果我通过IPv6连接,一切都很好。这在Linux和MacOS上都会发生。我有一个完整的例子来说明我所说的 我不认为我在做什么特别花哨的事。整个代码都在GitHub上,但本质上我的程序是: (def my-channel (permanent-channel)) (defroutes app-routes (GET "/events" [] {:headers {"Content-Type" "text/event-str

我正在尝试在中设置服务器发送事件,但它无法在IPv4上工作。如果我通过IPv6连接,一切都很好。这在Linux和MacOS上都会发生。我有一个完整的例子来说明我所说的

我不认为我在做什么特别花哨的事。整个代码都在GitHub上,但本质上我的程序是:

(def my-channel (permanent-channel))

(defroutes app-routes
  (GET "/events" []
    {:headers {"Content-Type" "text/event-stream"}
     :body my-channel}))

(def app
  (handler/site app-routes))

(start-server (wrap-ring-handler app) {:port 3000}))
但是,当我连接到
127.0.0.1:3000
时,我可以看到curl发送请求头,但它只是挂起,从不打印响应头:

$ curl -vvv http://127.0.0.1:3000/events

* About to connect() to 127.0.0.1 port 3000 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7f920a004400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f920a004400) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET /events HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:3000
> Accept: */*
如果我通过IPv6连接,响应会立即出现,并且我在通道中排队的事件会正确发送:

$ curl -vvv http://localhost:3000/events

* Adding handle: conn: 0x7f943c001a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f943c001a00) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 3000 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 3000 (#0)
> GET /events HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:3000
> Accept: */*
>
< HTTP/1.1 200 OK
* Server aleph/0.3.0 is not blacklisted
< Server: aleph/0.3.0
< Date: Tue, 15 Apr 2014 12:27:05 GMT
< Connection: keep-alive
< Content-Type: text/event-stream
< Transfer-Encoding: chunked
$curl-vvvhttp://localhost:3000/events
*添加句柄:conn:0x7f943c001a00
*正在添加句柄:发送:0
*正在添加句柄:recv:0
*卷曲度加把手尺寸线:长度:1
*-接头0(0x7f943c001a00)发送管道:1,接收管道:0
*即将连接()到本地主机端口3000(#0)
*正在尝试::1。。。
*已连接到本地主机(::1)端口3000(#0)
>GET/events HTTP/1.1
>用户代理:curl/7.30.0
>主机:localhost:3000
>接受:*/*
>
我也在Chrome中复制了这种行为。在IPv4和IPv6两种情况下,
tcpdump
显示响应头是通过线路传输的

这种行为在
lein run
和uberjar中都会发生。如果使用
-Djava.net.preferIPv4Stack=true执行uberjar,也会发生这种情况


如何使我的应用程序在IPv4上的行为与在IPv6上的行为相同?

当我运行您的示例IPv4和IPv6挂起时,您使用的是什么版本的Java?我使用的是OpenJDK 1.6和Java 1.7u45。ip4和ip6都适用于Mac+Java 1.6.0