简体   繁体   中英

Pusher App events not triggering

I'm testing out the Pusher library for handling websockets with a rather simple app using PHP and Javscript (jQuery) you can find it here: http://jsfiddle.net/JyVvr/1/

Tha backend ajax.php file contains this:

require 'lib/Pusher.php';

$message = $_POST['msg'];

$pusher = PusherInstance::get_pusher(); // My API key, secret, etc is directly set in the Pusher.php file

$pusher->trigger(
    'test_channel',
    'new_comment',
    array('message' => $message)
);

echo json_encode(array('message' => $message));

Basically the app just takes a message and appends it to the ul element on form submit, the appending part works just fine but the new_comment event isn't triggering so the app isn't working as intended, I used an alert just to test if it showed but it just does nothing plus it doesn't throw any errors or anything. Can anyone tell me what am I doing wrong?

Thanks in advance!

If the events aren't reaching Pusher, make sure the Pusher server time and your server time match or are within 599s of each other. I've been trying to figure this out recently and this article was the first one to appear, so just mentioning this for others to save them some time and headache.

Take a look at the Pusher Debug Console for your app. If you don't see your event triggered in there then it's either not reaching or is not being accepted by the Pusher REST API.

There aren't any issued raised about this Pusher PHP library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM