Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello I have an issue but cannot debug due to lack of log files #349

Closed
shirofuji opened this issue Aug 18, 2015 · 6 comments
Closed

Hello I have an issue but cannot debug due to lack of log files #349

shirofuji opened this issue Aug 18, 2015 · 6 comments
Labels

Comments

@shirofuji
Copy link

Hi ratchet dev,

I have developed a websocket server which is running good for a couple of months, unfortunately, just recently I have encountered an error telling showing the following message:

Connection reset by peer

upon connecting to websocket. I have also encountered another error where websocket doesn't accept my connection but shows no error. Do you have any encounters like this?

@cboden
Copy link
Member

cboden commented Aug 19, 2015

This could be a number of things. If this error happens very rarely it is most likely the client closed the socket and you attempted to send a message to the resource after. If this starts happening a lot after a period of time it's likely you're hitting your open file limit for the application. Most system defaults are 256 or 1024 which is very low for a server. You'll need to increase that.

@shirofuji
Copy link
Author

Hi, thanks that makes sense, just a follow up question. If I enclose ConnectionInterface->send inside a try catch would it avoid the error (assuming the error is caused by your first statement). Also, can you enlighten me about the open file limit? I am using two servers which is load balanced so would that help, solving the problem if the error is caused by your second statement?

@cboden
Copy link
Member

cboden commented Aug 20, 2015

I'm pretty sure Connection reset by peer is a warning not an exception, so I don't think try/catch would do anything. If that message is an exception Ratchet is wrapped in a try/catch and passed up through onError methods.

I suggest just googling "open file limit" for your OS. Different OS' (even different Linux distros) have different methods of handling this, many systems even have a layered check where you'll have to adjust it in 3 places (for security reasons) to take effect.

@shirofuji
Copy link
Author

Hi ratchet dev,

I have increase open file limits on my server, and recently I found a way to recreate this kind of error. First I opened up as many connections as I can, then I create a code that will try to send messages to my server replicating real world scenario, by the way I am using push integration. While doing this I have one terminal running top to monitor my cpu and memory utilization, and one consistently running cat /proc/sys/fs/file-nr, it seems that the websocket server code does not reach open file limit but reaches 100% cpu usage. once the cpu usage reach 100% the code will still run but refuse to accept incoming connections. Any ideas on how to maybe optimize my code?

@shirofuji
Copy link
Author

Hi ratchet dev,

By the way, I am logging a var_dump of the event_loop object in my code. At first it was a StreamSelectLoop instance, so I tried to install libevent. Now that I've installed libevent the code somehow got more stable, but I can still recreate the error. The only difference now is that the code does not crash, instead it freezes until cpu usage get lower.

@mbonneau
Copy link
Member

Closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants