ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 376 forks source link

Script sleep at sending response to users #20

Closed ASHKARAN closed 7 years ago

ASHKARAN commented 9 years ago

Hi thanks for your project !

I have a problem with this script, when my clients are more than 15-20 people server sleep at sending back message and cant handle a lot messages.... and i don't know whats wrong with this !

output sourcecode

ghedipunk commented 9 years ago

I'll have to investigate further. I have not tested with more than 10 connections at a time.

ASHKARAN commented 9 years ago

I made a web page that send 100 message to the server per seconds.... and i opened 10 page, so the server has 1000 message to process per second ... each process take 0.02 seconds time....

May the problem exist because of the buffer ? Or need to be flushed ?! Shall we use threading or something else?

The main problem is this, that we have no error , and script hangs. Thanks for your time.

indulodha commented 9 years ago

Hi, Just wanted to check if you got a solution for this. I have websockets which keep sleeping and start working after sometime.

Thanks for the help.

vikashbbd commented 9 years ago

I am also facing the same. Solutions please.

ghedipunk commented 9 years ago

Still open. Will take another look this evening.

If anyone can come up with the most direct steps to reproduce by the time I'm able to look at this in greater detail (about 12 hours from now), I'd greatly appreciate it.

vikashbbd commented 9 years ago

I don't think there is any specific use case. I feel its just intermittent. May be something s blocking?

Xaraknid commented 9 years ago

I think @vikashbbd pinpoint it. It's because socket are in blocking mode right now. That mean when sending message it's block untill the message was sent completely, do that for every socket client. Unnoticable if the message was sent in one or two packets. But you can see "sleeping" when your message was sent over several packets.

When socket are use in NON BLOCKING mode it's the job of application to check if the message was sent completely or not and buffer it to send it in next loop.

There is allready a working solution, but it's in development branch . Who still need some feature to meet the vision of @ghedipunk for the future of this project.

ASHKARAN commented 9 years ago

As a solution i'm using ratchet. Ratchet is a PHP WEBSOCKET server which is using NON-BLOCKING system !

On Wed, May 27, 2015 at 10:59 AM, Xaraknid notifications@github.com wrote:

I think @vikashbbd https://github.com/vikashbbd pinpoint it. It's because socket are in blocking mode right now. That mean when sending message it's block untill the message was sent completely, do that for every socket client. Unnoticable if the message was sent in one or two packets. But you can see "sleeping" when your message was sent over several packets.

When socket are use in NON BLOCKING mode it's the job of application to check if the message was sent completely or not and buffer it to send it in next loop.

There is allready a working solution, but it's in developpement branch . Who still need some feature to meet the vision of @ghedipunk https://github.com/ghedipunk for the future of this project.

— Reply to this email directly or view it on GitHub https://github.com/ghedipunk/PHP-Websockets/issues/20#issuecomment-105773300 .