javascriptajaxcrashchat

Web site crashes after longer usage


I am building a web site on a free web site provider (000webhost) and I am currently working on a chat. I have set an interval every 500ms which reads a file and checks if a new message was posted. If there is a new one, i load all messages from a .txt-file into a element in html. It is nearly finished but after long chatting or just being on the chat-page (3 minutes or more), my site crashes and I have to wait about an hour till i can access it. I am refreshing the chat using JavaScript and ajax every half second.

Does anybody know what I could have done wrong? I already searched Google for that issue but couldn't find any help.

Edit:
I changed the interval for refreshing the chat to 2,5 seconds and the web site didn't crash. I think that solved the problem..


Solution

  • Sounds like the host is blocking you, maybe due to excessive requests. One request every 500 milliseconds from the same IP can probably be mistaken for a DOS-attack or similar.

    There are more performant and suitable ways to build a chat - have a look at web sockets or node.js for instance.

    Update

    As Tom points out in his comment, it might be that a free web host doesn't provide or allow you to setup a Node-server. In that case, I guess you could experiment with an increased request-interval, and see if that helps you, or check with the host if they have such a limit. An increased request interval would probably make the chat feel less responsive, but it is tough to get everything on a free host.