Using the AJAX technology alone the chat clients have to permanently pull updates from the server.
This is due to AJAX being a web technology and HTTP being a stateless protocol.
Events pushed from server-side need a permanent or long-lasting socket connection between clients and server.
This requires either a custom HTTP server (called "comet") or another custom socket server.
Clients without this requirement will fall back to pull the server for updates.
The socket server coming with AJAX Chat is implemented in Ruby.
You need to be able to run a Ruby script as a service to run the socket server.
To be able to start the service, the script files in the socket/ directory have to be executable:
chmod +x server chmod +x server.rb
- "server" is a simple bash script to start and stop a service.
- "server.rb" is the ruby socket server script.
- "server.conf" is a configuration file - each setting is explained with a comment.
To start the service, execute the "server" script with the parameter "start":
This will create two additional files:
- "server.pid" contains the process id of the service.
- "server.log" is filled with the socket server log.
To monitor the socket server logs, you can use the "tail" command included in most GNU/Linux distributions:
tail -f server.log
By default only errors and start/stop of the server are logged.
To get more detailed logs configure the log level by editing the configuration file.
To stop the service, execute the "server" script with the parameter "stop":
If the socket server is running, you have to enable the following option in lib/config.php:
// Defines if the socket server is enabled: $config['socketServerEnabled'] = true;
This tells the server-side chat script to broadcast chat messages via the socket server.
Chat clients will establish a permanent connection to the socket server to listen for chat messages.
By default only local clients (127.0.0.1,::1) may broadcast messages.
Clients allowed to broadcast messages may also handle the channel authentication.
If your socket server is running on another host you should set the broadcast_clients option to the chat server IP.
Using the socket server increases response time while improving server performance at the same time.
To start and stop the socket server, you can use the bash script included in the AJAX Chat packages. If stopping the chat server doesn't work, try changing
kill -TERM $PID
kill -HUP $PID
Since Flash 9,0,115,0 and all Flash 10 versions, permissions for creating sockets using Flash have changed. Particularly, now an explicit permission (using xml-syntax) is required for creating socket connections. So, in the current state, socket server won't work with the newest Flash versions. You will get a "Flash security error" in the browser.
A solution is to use a policy-files server which will listen to connections in port 843 in the server. Each time a client tries to connect to the chat, the Flash client will request the policy authorization to the server. I've tried the policy-files server downloadable from http://ammonlauritzen.com/FlashPolicyService-09b.zip and it works fine with FF3 and IE7 (didn't test any other browsers).
Long story short, if you activate the socket server but don't provide the policy files server, the socket server won't work in pre 9,0,115,0 Flash versions.
A more detailed explanation can be found here:
Official Adobe documentation:
If this works (you can use chat) but you continue to receive security errors, you can suppress these error messages by commenting out the following line in chat.js:
setTimeout('ajaxChat.addChatBotMessageToChatList(\'/error SocketSecurity\')', 0);
To further complicate matters, the Flash clients will always check port 843 first for a policy file before checking any other port you specify. You can install the sample policy server provided at
We recommend the Perl one. You will need to comment out the printing to STDERR to prevent interference with the chat's XML output.