这让我困扰了将近两天。
我正在写Bayeux客户端。我使用Jetty中的WebSocket-client库并连接到Faye服务器。
我通过握手请求打开与服务器(所有localhost)的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"}
然后服务器挂起45秒(超时值),然后发送此响应:
{"clientId":"l8xhgf0t5gikcukcknhr5npfx11s5w9","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":45000}}
Faye服务器挂起之前的最后一条日志消息:Ping" l8xhgf0t5gikcukcknhr5npfx11s5w9",45
但我从未在客户端收到Ping帧。 我不知道为什么服务器挂起那些45s,但我需要解决这个问题。 你以前见过这个人吗?任何帮助/建议/提示非常感谢:)
答案 0 :(得分:1)
您遇到的行为正是Bayeux服务器应该做的事情。
服务器没有“挂起”;它以long-polling方式保存请求。
我不太了解Faye,但定义CometD project的Bayeux protocol specification以相同的方式实现服务器,其中/meta/connect
消息请求被保留用于超时值