wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

error in JSONP old messages response #123

Closed megabuz closed 9 years ago

megabuz commented 10 years ago

sometimes i get array of messages without comma separators

[{"id":...}{"id":...}]

sometimes ngx_http_output_filter returns NGX_AGAIN (maybe when i have big message). So in ngx_http_push_stream_module_utils.c (line 516)

            if (rc == NGX_OK) {
                rc = ngx_http_push_stream_send_response_text(r, str->data, str->len, 0);
            }

            if ((rc == NGX_OK) && use_jsonp) {

rc can be NGX_AGAIN

i found answer in http://mailman.nginx.org/pipermail/nginx/2007-September/001791.html

If you have got all your data ready you may send them at once in one chain. But if you are getting then gradually, then after NGX_AGAIN you should set event handlers and timer and return control to nginx.

Can you fix this error? Thanks

wandenberg commented 10 years ago

Hi @megabuz

Please, split the issue on different "problems".

Receive old messages without comma separators is a expected behavior. You should put the comma on your template or use the JSONP support specifying a callback function when subscribing, take a look on examples. The basic long polling support don't set this because it is a generic protocol. It can have other uses, so the module do not "change the messages".

About the NGX_AGAIN it is a known issue and will be fixed on future version. From now you can increase the output buffers of sockets on you O.S. to minimize the number of errors or limit the publish message size.

Regards

megabuz commented 10 years ago

Receive old messages without comma separators is a expected behavior

Yes i know. I wrote "error in JSONP" in title

About the NGX_AGAIN it is a known issue and will be fixed on future version.

Thanks!

wandenberg commented 10 years ago

Can you send me how to reproduce the "error in JSONP" you are getting?

megabuz commented 10 years ago

I think you right about buffer size. I generated several big messages and use backlog option in pushstream.js to got it

in ngx_http_push_stream_module_utils.c line 517 https://github.com/wandenberg/nginx-push-stream-module/blob/master/src/ngx_http_push_stream_module_utils.c#L517 i got rc = NGX_AGAIN, so line 522 didn't work, and NGX_HTTP_PUSH_STREAM_CALLBACK_MID_CHUNK didn't write in buffer

wandenberg commented 9 years ago

The problem with NGX_AGAIN was solved on 0.5.1 tag (a48ca949427b782fba1722932f4881850c50b9f1)