I've had an ongoing problem with Chatroom 6.12, 6.13 and 6.14: Chats work as expected, but messages from another person participating in the chat appear only when I deliberately reload the page in the browser. Messages that I enter myself do appear in the chat window, after a delay of a few seconds. Please note, this is not something obvious like a missing chatroomread.php in the document root -- it's there, alongside index.php. I've found this problem quite puzzling and frustrating.

In Internet Explorer 8, after entering a message which appears in the window, I sometimes see the browser title bar refreshing about once per second, alternating between the title of the chat and the message just entered -- which suggests that something is happening by AJAX. In FireFox, I don't see this same behavior. But in both browsers, messages from any other person participating in the chat appear only when I deliberately reload the page in the browser.

I am using APC, memcache(d), and the Boost module. I see code in the Chatroom module that appears to deal with APC and memcache. I'd like to know if other users of Chatroom are also using these performance-boosting tools.

I really need to get this problem solved, would even pay for a solution. Thanks.

Comments

Anonymous’s picture

does it work without APC and Boost?

are there any errors?

i need more information to help you here....

AlexisWilke’s picture

Title: AJAX refresh not working » AJAX refresh not working with PostgreSQL
Assigned: Unassigned » AlexisWilke
Priority: Major » Critical
Status: Active » Needs review
Issue tags: +PostgreSQL
StatusFileSize
new1.47 KB

Wow! I don't get it... It works on one of my sites, but not the other. Then looking at the code I see these SQL statements:

SELECT cm.*, u.name, 0 guest_id FROM ...

MySQL improperly accepts those, you are missing the AS keyword for PostgreSQL. So you need this instead:

SELECT cm.*, u.name, 0 AS guest_id FROM ...

This is critical for all PostgreSQL users since it doesn't work otherwise and we get tons of errors in our Reports Log.

@dfylstra, can you confirm that the patch resolves your problem?

@justinrandell, at this time I only checked the .module file, if you have other similar SQL statements in the other files, then you'll want to fix them too!

Thank you.
Alexis Wilke

dfylstra’s picture

Title: AJAX refresh not working with PostgreSQL » AJAX refresh not working
Assigned: AlexisWilke » Unassigned
Priority: Critical » Major
Status: Needs review » Active
Issue tags: -PostgreSQL

I have one version of the site using memcache and Chatroom 6-x-2.13, and another version not using memcache and using Chatroom 6-x-2.14. Both sites exhibit this same behavior. Both of them use APC (which is quite important for my site), but I've tried turning off APC on the site that doesn't use memcache, and I still get the same behavior. I also disabled static page caching in Boost on this same site, and I still get the same behavior. Consistently, I see no updated contents in the chat window until I click the refresh button in the browser.

On the site that is using memcache and Chatroom 6-x-2.13, I did find the following error just now in my error log, where the referer is a Chatroom chat node. (Sorry for the long line, it's part of the error message.) But I mention this just for completeness. From the experiments above, I doubt that memcache is the source of my problem here. I haven't seen any other PHP or Apache errors that appear to relate to Chatroom in the error log.

Mon Apr 04 19:30:21 2011] [error] [client 216.82.144.137] PHP Warning: Duplicate entry 'variables' for key 1\nquery: INSERT INTO cache (cid, data, expire, created, headers, serialized) VALUES ('variables', 'a:1059:{s:13:\\"theme_default\\";s:23:\\"fusion_mysitetheme\\";s:13:\\"filter_html_1\\";i:1;s:18:\\"node_options_forum\\";a:1:{i:0;s:6:\\"status\\";}s:18:\\"drupal_private_key\\";s:64:\\"f4cd9a3fa1dea58bf339b4b811c3fb468b8a274c9fb8f565086cf5da950eb411\\";s:10:\\"menu_masks\\";a:41:{i:0;i:127;i:1;i:126;i:2;i:125;i:3;i:124;i:4;i:122;i:5;i:119;i:6;i:118;i:7;i:117;i:8;i:63;i:9;i:62;i:10;i:61;i:11;i:60;i:12;i:59;i:13;i:58;i:14;i:57;i:15;i:56;i:16;i:45;i:17;i:44;i:18;i:31;i:19;i:30;i:20;i:29;i:21;i:28;i:22;i:27;i:23;i:24;i:24;i:23;i:25;i:22;i:26;i:21;i:27;i:20;i:28;i:15;i:29;i:14;i:30;i:13;i:31;i:12;i:32;i:11;i:33;i:10;i:34;i:7;i:35;i:6;i:36;i:5;i:37;i:4;i:38;i:3;i:39;i:2;i:40;i:1;}s:13:\\"menu_expanded\\";a:1:{i:0;s:13:\\"primary-links\\";}s:26:\\"date_default_timezone_ in /var/www/vhosts/mysite.com/httpdocs/includes/database.mysqli.inc on line 135, referer: http://www.mysite.com/live-chat-sales-service

I am really puzzled by this. Is there some simple experiment I can try to isolate what's happening (or not happening) with chatroomread.php, perhaps just to confirm that it's being loaded?

dfylstra’s picture

I am using MySQL. My problem has nothing to do with PostgreSQL.

AlexisWilke’s picture

Right, well... 8-) You did not explain very much in your first message.

I have Boost, but I turned off the cache on that page. (when going to the Boost page you can do that by adding the path to the chat room. If you have many, make sure to put them all under a given path using pathauto.) I also have XCache which is the same as APC and it works.

First you could check the database. The table named chatroom_msg will show a list of the messages you typed. If you don't see them, then the AJAX does not even send the messages (it could be an Access Denied error.)

Note that does not invalidate my patch, but I guess that's a different issue and I should post it in a new issue. 8-)

Thank you.
Alexis

dfylstra’s picture

I also have my chat nodes listed in the Boost settings under "Statically cache specific pages: Cache every page except the listed pages." At the moment, I have "Boost - Static page cache" set to Disabled - but I get the same behavior, no automatically updated chats.

The table chatroom_msg does contain the list of messages typed in my testing. (This is consistent with the fact that the messages are visible to any user *after* reloading the page in the browser.) The uid field in this table reflects several different user accounts, but the recipient_uid field is always 0. The cmid field contains consecutive integers, as expected.

I've started digging further into the code: I see the Drupal.chatroom.poll and .pollHandler functions in chatroom.js, I see that it POSTs to chatroomread.php and it should get a response. I see that it passes an argument from Drupal.settings.chatroom.cacheDirectory - what should this be, how is it set? I haven't seen a Chatroom configuration option for a "cache directory" - Am I missing something?

I see at the top of chatroomread.php: if (!isset($_POST['chat_cache_directory']) || !is_dir($_POST['chat_cache_directory'])) { exit; } and I wonder if it is exiting without doing anything, if this argument is not a valid directory. What can I do to look further?

dfylstra’s picture

The Chatroom README file says "If your module folder is somewhere other than 'sites/all/modules/chatroom', set the path to the folder in settings.php: $conf['chatroom_module_dir'] = 'path/to/the/chatroom/module/directory';

My Chatroom module is at the normal path, sites/all/modules/chatroom, and it's writable. But I tried setting this $conf array element anyway: first $conf['chatroom_module_dir'] = 'sites/all/modules/chatroom'; then the full path from the root on my server. But this had no effect: New messages still appear in the chat window when I reload the page in the browser, but otherwise they appear only for the user who typed them in, not for any other user.

Still seeking suggestions or ideas...

Anonymous’s picture

re #6, from chatroom.module:

    'cacheDirectory' => file_directory_temp(),

don't guess about the chatroomread.php stuff - before each exit, add a print "some debug string"; or whatever you like so you know where its failing, then report back.

AlexisWilke’s picture

On one of my servers I had to tweak my modsecurity module. But if you can see the messages after a Reload, I don't think that's the problem.

The other thing I ran into was the permissions. You need to assign the first one "access chat rooms", and until you do that, it feels like it is working, but you really get an invisible access denied. (although I think it should appear in your logs...)

Thank you.
Alexis

tacituseu’s picture

Can be caused by strongarm's hook_init() implementation:

function strongarm_init() {
  strongarm_set_conf();

  // This is a workaround for the very early check of the 'site_frontpage'
  // variable in the Drupal bootstrap process. The workaround re-runs
  // drupal_init_path() to ensure the strongarm'ed version of
  // 'site_frontpage' is used. Note that this may be too late if other modules
  // weighted even lower than strongarm (which is a superlightweight -1000)
  // rely on $_GET['q'] or 'site_frontpage' in hook_init().
  $_GET['q'] = isset($_REQUEST['q']) ? strongarm_language_strip($_REQUEST['q']) : NULL;
  drupal_init_path();
}

to fix it change chatroomread.php to:

// Make this look like a normal request to Drupal, then execute index.php.
$_REQUEST['q'] = $_GET['q'] = "chatroom/chat/get/latest/messages/$chat_id/$client_latest_msg_id"; 
dfylstra’s picture

My site does have the strongarm module - it is a Drupal Commons based site, and the DC profile includes strongarm. So I tried this in chatroomread.php:

$_REQUEST['q'] = $_GET['q'] = "chatroom/chat/get/latest/messages/$chat_id/$client_latest_msg_id";

But I'm afraid it didn't make any difference. I still see no updated contents in the chat window until I click the refresh button in the browser.

I do have the 'access chat rooms' and 'access chats' permissions assigned to the authenticated user role, and I'm testing with logged-in users.

I will try printing some debug information at various points in chatroomread.php - but this will happen in about five days, since in one day I'm leaving for a major conference/trade show for my company. I do appreciate the suggestions above.

tacituseu’s picture

You can tell it's strongarm issue by the size/content of AJAX reply, normally it's JSON under one KB, with strongarm '/node' gets returned.

pivica’s picture

Version: 6.x-2.14 » 6.x-2.x-dev
StatusFileSize
new458 bytes

I had the same problem (chatroom with acquia commons distro didn't worked because of strongarm module) like in #10 and came to the same solution.

Anonymous’s picture

Status: Active » Fixed
dfylstra’s picture

I'm back from the conference/trade show in #11; I am keeping the patch in #10 on my site. But as before, I see no updated contents in the chat window until I click the refresh button in the browser, in both IE and FireFox.

I put some error_log() calls into chatroomread.php. The first one occurs before any conditional tests, and should write a message if chatroomread.php is being loaded and executed at all. I'm not getting any messages, even when I type entries in the "Enter your message text here:" box and press Enter, or when I reload the Chat node page in the browser.

I do see the chatroom.js file referenced on the page, and I do see "$(document).ready(function () {
setInterval("Drupal.chatroom.poll()", Drupal.settings.chatroom.pollInterval * 1000); ..." in this file. I just do not see what is wrong.

Any ideas would be appreciated.

Anonymous’s picture

@dfylstra - ok, can you try putting some debug text in chatroomread.php, and report back where its failing?

Anonymous’s picture

oh, i missed the error_log() stuff in #15.

ok, can you paste the relevant values in javascript settings, that is, everything in Drupal.settings?

also, if you just paste

http://your.domain/chatroomread.php

in the browser, do you get logging from your error_log() tests?

oriol_e9g’s picture

I have try the patch in #13 and this solves my problems in http://drupal.org/node/175254

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.