Bayeux 服务器挂起连接请求

Bayeux server hangs on connect request

这困扰了我将近两天。

我正在编写 Bayeux 客户端。我使用 WebSocket-client library from Jetty and connecting to Faye 服务器。

我使用握手请求打开到服务器的 WS 连接(所有本地主机):

{"channel":"/meta/handshake","supportedConnectionTypes":["long-polling","callback-polling","websocket"],"version":"1.0"}

客户端立即收到握手响应:

{"channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"l8xhgf0t5gikcukcknhr5npfx11s5w9","advice":{"reconnect":"retry","interval":0,"timeout":45000}}

然后客户端发送连接请求:

{"clientId":"l8xhgf0t5gikcukcknhr5npfx11s5w9","connectionType":"websocket","channel":"/meta/connect"}

然后服务器挂起45s(超时值)然后发送这个响应:

{"clientId":"l8xhgf0t5gikcukcknhr5npfx11s5w9","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":45000}}

Faye 服务器挂起前的最后一条日志消息:Ping "l8xhgf0t5gikcukcknhr5npfx11s5w9"、45

但我从未在客户端收到 Ping 帧。 我不知道为什么服务器会在 45 秒后挂起,但我需要解决这个问题。 你们中有人见过这个吗?非常感谢 help/suggestions/hints :)

您遇到的行为正是 Bayeux 服务器应该做的。

服务器没有"hang";它以 long-polling 的方式保存请求。

我对Faye了解不多,但是CometD project, which defined the Bayeux protocol specification,以同样的方式实现了一个服务器,其中/meta/connect消息请求被保持超时值。