j3k0 / ganomede-notifications

Long-pull notification service for Ganomede
0 stars 0 forks source link

Should return json [] on timeout #2

Closed j3k0 closed 9 years ago

j3k0 commented 9 years ago

For now, it seems to returns

<HTML></HTML>
elmigranto commented 9 years ago

Wouldn't it be better to just reply with HTTP 408 Request Timed Out (restify.RequestTimeoutError), so client knows he should resend its long polling request?

j3k0 commented 9 years ago

I'd better send a success code 200 here.

Why?

In case of any non success (2xx) reply, the client will wait an increasing number of seconds before retrying. In case of a successful reply (empty or not), the client will re-poll immediately.

Then, we will have to do an exception for the 408 status reply.

Problems will occur if we're not able to differentiate between the unexpected timeout and expected timeout. If the server is overloaded, there will be an unexpected timeout, registry's proxy will reply with a 408 status already.