kakserpom / phpdaemon

Asynchronous server-side framework for network applications implemented in PHP using libevent
http://daemon.io/
GNU Lesser General Public License v3.0
1.53k stars 231 forks source link

Hangs when not in use for a long time #209

Closed yefrem closed 9 years ago

yefrem commented 9 years ago

Hi. I've set up chat server using phpDaemon and WebSockets. It's not published yet so is only used by test users. I've noticed that if I don't connect and send any messages for about 2 days it hangs, clients cannot connect and phpd restart is needed. Is there any way to fix or track it?

kakserpom commented 9 years ago

What happens?

yefrem commented 9 years ago

uhm, I just described:) I have a WebSocket chat server. It works well, receives and sends messages and so on. But if nobody uses it for about two days it stops accepting clients (hangs). Browser console shows connection error and I should restart phpd to get it working again.

kakserpom commented 9 years ago

I was wondering what you particularly meant by 'hanging'. Try to use max-idle 15m; to have workers restarted after being idle for at least 15 minutes (for instance).

yefrem commented 9 years ago

Tried max-idle but it didn't help, hung again after several days of silence. Is there any other info I should provide?

kakserpom commented 9 years ago

What if you pkill workers instead of restarting whole daemon?

yefrem commented 9 years ago

what should I actually check? wait until it hangs, then kill workers and see if they will be respawned?

kakserpom commented 9 years ago

Exactly so.

yefrem commented 9 years ago

So I contacted server admin and he did what you told me. Workers restarted but server still did not respond (client could not connect) until I did "phpd restart".

kakserpom commented 9 years ago

Quick fix: 'user root;' and remove 'privileged;' from the pool section in config.

yefrem commented 9 years ago

sadly didn't help :(

yefrem commented 9 years ago

Finally I discovered that the problem was caused by errors in my authorization process which caused client disconnection. So I'm going to close this issue. Only one little question: how do I get client IP address when using WebSockets?

UPD: found it in source code. Closing issue, sorry for wasting your time.