javawebsocketfayebayeux

Bayeux server hangs on connect request


this is bugging me for almost two days.

I'm writing Bayeux client. I use WebSocket-client library from Jetty and connecting to Faye server.

I open a WS connection to the server (everything localhost) with handshake request:

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

The client immediately receives a handshake response:

{"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}}

Then client sends connect request:

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

Then the server hangs for 45s (the value of time out) and then sends this response:

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

last log message on Faye server before it hangs: Ping "l8xhgf0t5gikcukcknhr5npfx11s5w9", 45

But I never receive Ping frame on client side. I have no idea why the server hangs for those 45s, but I need to resolve this. Have anyone of you seen this before? Any help/suggestions/hints much appreciated :)


Solution

  • The behaviour you are experiencing is exactly what a Bayeux server should do.

    The server does not "hang"; it holds the request in a long-polling fashion.

    I don't know much Faye but the CometD project, which defined the Bayeux protocol specification, implements a server in the same way, where the /meta/connect message request is held for the timeout value.