Error wiith babble


Kjell Iver Johansen
  • Not Specified Closed Bug

Hello Michael

Yesterday I abandoned the trial, just to test my own server before they close the chat on IPS.

Now - I'm totally lost in setting up the node.js and the server, but my co-admin has set it up according to your setup

I can only wite one sentence - then I get - can't connect to node.js

I now notice that my serverlog is filled with the following error

ElephantIO\Exception\ServerConnectionFailureException
0: An error occurred while trying to establish a connection to the server
#0 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(48): ElephantIO\Engine\SocketIO\Version1X->handshake()
#1 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect()
#2 /home/kjiver/fjellforum.no/applications/babble/sources/Sockets/Sockets.php(101): ElephantIO\Client->initialize()
#3 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(59): IPS\babble\_Sockets->post('Adrgha has repl...', Object(IPS\Member), '4,8,10,2,3,6,11...', Array)
#4 /home/kjiver/fjellforum.no/system/Content/Comment.php(171): IPS\forums\Topic\babble_hook_ipsForumsTopicPost->save()
#5 [internal function]: IPS\Content\_Comment::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL, NULL, Object(IPS\Member), NULL, NULL, NULL)
#6 /home/kjiver/fjellforum.no/applications/forums/sources/Topic/Post.php(132): call_user_func_array('parent::create', Array)
#7 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(27): IPS\forums\Topic\_Post::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL, NULL, NULL, NULL, NULL, NULL)
#8 /home/kjiver/fjellforum.no/system/Content/Item.php(3700): IPS\forums\Topic\cms_hook_Post::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL)
#9 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(58): IPS\Content\_Item->processCommentForm(Array)
#10 /home/kjiver/fjellforum.no/system/Content/Item.php(3551): IPS\Content\hook545->processCommentForm(Array)
#11 /home/kjiver/fjellforum.no/applications/forums/modules/front/forums/topic.php(116): IPS\Content\_Item->commentForm()
#12 /home/kjiver/fjellforum.no/system/Dispatcher/Controller.php(96): IPS\forums\modules\front\forums\_topic->manage()
#13 /home/kjiver/fjellforum.no/system/Content/Controller.php(51): IPS\Dispatcher\_Controller->execute()
#14 /home/kjiver/fjellforum.no/applications/forums/modules/front/forums/topic.php(40): IPS\Content\_Controller->execute()
#15 /home/kjiver/fjellforum.no/system/Dispatcher/Dispatcher.php(129): IPS\forums\modules\front\forums\_topic->execute()
#16 /home/kjiver/fjellforum.no/index.php(13): IPS\_Dispatcher->run()
#17 {main}
  
  
  backtrace
  #0 /home/kjiver/fjellforum.no/applications/babble/sources/Sockets/Sockets.php(180): IPS\_Log::log('ElephantIO\\Exce...')
#1 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(59): IPS\babble\_Sockets->post('Adrgha has repl...', Object(IPS\Member), '4,8,10,2,3,6,11...', Array)
#2 /home/kjiver/fjellforum.no/system/Content/Comment.php(171): IPS\forums\Topic\babble_hook_ipsForumsTopicPost->save()
#3 [internal function]: IPS\Content\_Comment::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL, NULL, Object(IPS\Member), NULL, NULL, NULL)
#4 /home/kjiver/fjellforum.no/applications/forums/sources/Topic/Post.php(132): call_user_func_array('parent::create', Array)
#5 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(27): IPS\forums\Topic\_Post::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL, NULL, NULL, NULL, NULL, NULL)
#6 /home/kjiver/fjellforum.no/system/Content/Item.php(3700): IPS\forums\Topic\cms_hook_Post::create(Object(IPS\forums\Topic), '\n<blockquote cl...', false, NULL)
#7 /home/kjiver/fjellforum.no/init.php(443) : eval()'d code(58): IPS\Content\_Item->processCommentForm(Array)
#8 /home/kjiver/fjellforum.no/system/Content/Item.php(3551): IPS\Content\hook545->processCommentForm(Array)
#9 /home/kjiver/fjellforum.no/applications/forums/modules/front/forums/topic.php(116): IPS\Content\_Item->commentForm()
#10 /home/kjiver/fjellforum.no/system/Dispatcher/Controller.php(96): IPS\forums\modules\front\forums\_topic->manage()
#11 /home/kjiver/fjellforum.no/system/Content/Controller.php(51): IPS\Dispatcher\_Controller->execute()
#12 /home/kjiver/fjellforum.no/applications/forums/modules/front/forums/topic.php(40): IPS\Content\_Controller->execute()
#13 /home/kjiver/fjellforum.no/system/Dispatcher/Dispatcher.php(129): IPS\forums\modules\front\forums\_topic->execute()
#14 /home/kjiver/fjellforum.no/index.php(13): IPS\_Dispatcher->run()
#15 {main}

 





User Feedback


if you are using the trial version (2.2.9) you will need to roll back to the public version of 2.2.3, as it communicates radically different with the node server than 2.2.9 does. also make sure "allow_url_fopen" is set to ON in php as the elephant.io requires that (along with IPS sockets).

Share this comment


Link to comment
Share on other sites
23 minutes ago, Michael said:

if you are using the trial version (2.2.9) you will need to roll back to the public version of 2.2.3, as it communicates radically different with the node server than 2.2.9 does. also make sure "allow_url_fopen" is set to ON in php as the elephant.io requires that (along with IPS sockets).

OKI, I will check allow_url_fopen. The version was changed. i uninstalled before installing last version..

Share this comment


Link to comment
Share on other sites

I tracked down the error to be something wrong with the key - so when the man having my server altered the secret key the chat was working.

But still: people enter the room without beeing visible on the right side.

Should I enter something here?  Enable SSL Context Options ? I use https..

And the eroorlogs in ACP are overflown with stuff like this

ElephantIO\Exception\ServerConnectionFailureException
0: An error occurred while trying to establish a connection to the server
#0 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(48): ElephantIO\Engine\SocketIO\Version1X->handshake()
#1 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect()
#2 /home/kjiver/fjellforum.no/applications/babble/sources/Sockets/Sockets.php(263): ElephantIO\Client->initialize()
#3 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(561): IPS\babble\_Sockets->counts()
#4 [internal function]: IPS\babble\modules\front\view\_view->counts()
#5 /home/kjiver/fjellforum.no/system/Dispatcher/Controller.php(85): call_user_func(Array)
#6 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(255): IPS\Dispatcher\_Controller->execute()
#7 /home/kjiver/fjellforum.no/system/Dispatcher/Dispatcher.php(129): IPS\babble\modules\front\view\_view->execute()
#8 /home/kjiver/fjellforum.no/index.php(13): IPS\_Dispatcher->run()
#9 {main}

 

Share this comment


Link to comment
Share on other sites

if you are doing a reverse proxy in nignx or a proxy in babble, you might need to do the ssl context options. however if you have setup babble.js to use https (by including the paths to your key and cert) then you should be good. 

Share this comment


Link to comment
Share on other sites
32 minutes ago, Michael said:

if you are doing a reverse proxy in nignx or a proxy in babble, you might need to do the ssl context options. however if you have setup babble.js to use https (by including the paths to your key and cert) then you should be good. 

OK - I disabled babble for the moment due to that error. Is there something else I could be looking for?

Share this comment


Link to comment
Share on other sites

without knowing if you went with the reverse proxy/proxy route or setup babble.js to use ssl, i couldn't say.

Share this comment


Link to comment
Share on other sites
On 1/31/2017 at 7:04 PM, Michael said:

without knowing if you went with the reverse proxy/proxy route or setup babble.js to use ssl, i couldn't say.

Hello -  yes we are using nginx reverse proxy. Still have the same issue..

Share this comment


Link to comment
Share on other sites

I would drop the reverse proxy and configure babble.js to use ssl (by adding your cert and privatekey to the babble.js in the places for it). it works much better this way imho as the proxy's are slow. 

if you want to use the reverse proxy, one thing you can try, in the Node Settings tab in General and enable "alt url" and follow the directions for alt url in the apache proxy configuration.

 

Share this comment


Link to comment
Share on other sites

Hello Michael. Yesterday we tried again with settings as you described over - and all was functioning very well for a few hours.

But users with android and IOS did not get connect to Node. And the scrolling did not work.

After a few hours several users on PC complained that they got disconnected from node and I had to abandon..

I see that in my errorlogs I get the following error

UnexpectedValueException
0: The server returned an unexpected value. Expected "HTTP/1.1 101", had ""
#0 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(65): ElephantIO\Engine\SocketIO\Version1X->upgradeTransport()
#1 /home/kjiver/fjellforum.no/applications/babble/sources/3rdparty/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect()
#2 /home/kjiver/fjellforum.no/applications/babble/sources/Sockets/Sockets.php(263): ElephantIO\Client->initialize()
#3 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(561): IPS\babble\_Sockets->counts()
#4 [internal function]: IPS\babble\modules\front\view\_view->counts()
#5 /home/kjiver/fjellforum.no/system/Dispatcher/Controller.php(85): call_user_func(Array)
#6 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(255): IPS\Dispatcher\_Controller->execute()
#7 /home/kjiver/fjellforum.no/system/Dispatcher/Dispatcher.php(129): IPS\babble\modules\front\view\_view->execute()
#8 /home/kjiver/fjellforum.no/index.php(13): IPS\_Dispatcher->run()
#9 {main}

 

#0 /home/kjiver/fjellforum.no/applications/babble/sources/Sockets/Sockets.php(271): IPS\_Log::log('UnexpectedValue...')
#1 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(561): IPS\babble\_Sockets->counts()
#2 [internal function]: IPS\babble\modules\front\view\_view->counts()
#3 /home/kjiver/fjellforum.no/system/Dispatcher/Controller.php(85): call_user_func(Array)
#4 /home/kjiver/fjellforum.no/applications/babble/modules/front/view/view.php(255): IPS\Dispatcher\_Controller->execute()
#5 /home/kjiver/fjellforum.no/system/Dispatcher/Dispatcher.php(129): IPS\babble\modules\front\view\_view->execute()
#6 /home/kjiver/fjellforum.no/index.php(13): IPS\_Dispatcher->run()
#7 {main}

 

 

Share this comment


Link to comment
Share on other sites

open up applications/babble/sources/Sockets/Socket.php, find the method ioClient(), inside the method, after this line:

        require_once( \IPS\ROOT_PATH . '/applications/babble/sources/3rdparty/vendor/autoload.php' );
add:

$options['timeout'] = 10;

i remember you or someone else had a similar issue with this. 

Share this comment


Link to comment
Share on other sites
33 minutes ago, Michael said:

after this line:

        require_once( \IPS\ROOT_PATH . '/applications/babble/sources/3rdparty/vendor/autoload.php' );

I can't find that line.. this is my socketc php

Spoiler

<?php

/**
 * @brief       Sockets Class
 * @author      -storm_author-
 * @copyright   -storm_copyright-
 * @package     IPS Social Suite
 * @subpackage  Babble
 * @since       1.0.0 Beta 1
 * @version     -storm_version-
 */

namespace IPS\babble;

if( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
    header( ( isset( $_SERVER[ 'SERVER_PROTOCOL' ] ) ? $_SERVER[ 'SERVER_PROTOCOL' ] : 'HTTP/1.0' ) . ' 403 Forbidden' );
    exit;
}


class _Sockets extends \IPS\Patterns\Singleton
{
    
    protected static $instance = null;
    
    /**
     * @brief we use a php based client to handle some of the things we do in babble. Useful since it is nodejs based.
     * @return \ElephantIO\Client
     */
    public function ioClient()
    {
        require_once( \IPS\ROOT_PATH . '/applications/babble/sources/3rdparty/vendor/autoload.php' );

        if( \IPS\Settings::i()->babble_admin_config_general_node_use_alt )
        {
            $handshake = \IPS\Settings::i()->babble_admin_config_general_node_url_alt;
        }
        else
        {
            $handshake = \IPS\Settings::i()->babble_admin_config_general_node_url;
        }
        
        if( \IPS\babble\Build::old() )
        {
            $url = new \IPS\Http\Url( \IPS\Settings::i()->babble_admin_config_general_node_url );
        }
        else
        {
            $url = \IPS\Http\Url::createFromString( \IPS\Settings::i()->babble_admin_config_general_node_url );
        }
        
        if( $url->data[ 'scheme' ] === "https" )
        {
            $default = [ "verify_peer" => false, "verify_peer_name" => false ];
            
            $new = [];
            if( \IPS\Settings::i()->babble_admin_config_bot_general_config_use_context )
            {
                if( \IPS\Settings::i()->babble_admin_config_bot_general_config_other )
                {
                    $extra = \json_decode( \IPS\Settings::i()->babble_admin_config_bot_general_config_other, true );
                    
                    if( \is_array( $extra ) and \count( $extra ) )
                    {
                        foreach( $extra as $key => $val )
                        {
                            if( $val[ 'key' ] )
                            {
                                $new[ $val[ 'key' ] ] = $val[ 'value' ];
                            }
                        }
                    }
                }
            }
            
            $options[ 'context' ][ 'ssl' ] = \array_merge( $default, $new );
        }
        
        $options[ 'version' ] = 3;

        return new \IPS\babble\Sockets\Client( new \IPS\babble\Sockets\Engine( $handshake, $options ) );
        
    }
    
    /**
     * @todo refactor this thing is a mess
     * @brief used by the bots to run thru the \IPS\babble\Build::i()->insertMessage
     * @param $msg
     * @param $member
     * @param string $perms
     * @param array $extra
     * @return array
     */
    public function post( $msg, \IPS\Member $member, $perms = "*", $extra = [] )
    {
        try
        {
            $client = $this->ioClient();
            
            $client->initialize();
            
            $extras = [
                'perms' => $perms,
            ];

            if( isset( $_SERVER['SERVER_NAME'] ) )
            {
                \IPS\Request::i()->socket = $client->getId();
            }
            else
            {
                $extras['socket'] = $client->getId();
            }

            $extra = \array_merge( $extras, $extra );
            
            $data = \IPS\babble\Build::i()->insertMessage( $msg, $member, $extra );
            
            if( isset( $data[ 'html' ] ) or isset( $data[ 'text' ] ) or isset( $data[ 'alttext' ] ) )
            {
                if( isset( $data[ 'html' ] ) )
                {
                    $html = $data[ 'html' ];
                    
                    $member->language()->parseOutputForDisplay( $html );
                    
                    \IPS\Output::i()->parseFileObjectUrls( $html );
                    
                    $data[ 'html' ] = $html;
                }
                
                if( isset( $data[ 'text' ] ) )
                {
                    $html = $data[ 'text' ];
                    
                    $member->language()->parseOutputForDisplay( $html );
                    
                    \IPS\Output::i()->parseFileObjectUrls( $html );
                    
                    $data[ 'text' ] = $html;
                }
                
                if( isset( $data[ 'alttext' ] ) )
                {
                    $html = $data[ 'alttext' ];
                    
                    $member->language()->parseOutputForDisplay( $html );
                    
                    \IPS\Output::i()->parseFileObjectUrls( $html );
                    
                    $data[ 'alttext' ] = $html;
                }
            }
            
            if( $extra[ 'bot' ] )
            {
                $data[ 'delay' ] = 1000;
                $data[ 'bot' ] = 1;
            }
            
            if( $perms == "*" )
            {
                $data[ 'check' ] = "*";
            }
            else
            {
                $data[ 'check' ] = \explode( ',', $perms );
            }
            
            $client->emit( 'notify', $data );
            
            $client->close();
            
            return $data;
        }
        catch( \Exception $exception )
        {
            
            \IPS\Log::log( \get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
        }
    }
    
    /**
     * @brief adds the user to the online list, since we can't emit to ourself, this is useful.
     * @return array
     */
    public function connectedOnline()
    {
        try
        {
            $m = \IPS\babble\Member::i();
            
            $memberData = $m->memberOnlineData();
            
            if( isset( \IPS\Request::i()->cookie[ 'anon_login' ] ) )
            {
                $data = [ 'room' => $memberData[ 'room' ] ];
            }
            else
            {
                $data = $memberData;
            }
            
            $client = $this->ioClient();
            
            $client->initialize();
            
            $client->emit( 'add', $data );
            
            $client->close();
            
            $room = $m->room();
            
            if( class_exists( '\\IPS\\babble\\Stats' ) )
            {
                if( $room->stats )
                {
                    $member = $m->member();
                    
                    $rooms = \IPS\babble\Rooms::load( $room->id );
                    
                    if( $rooms->daily_cache )
                    {
                        $cache = json_decode( $rooms->daily_cache, true );
                        
                        if( !isset( $cache[ $member->member_id ] ) )
                        {
                            $cache[ $member->member_id ] = 1;
                            
                            $rooms->daily_count = $rooms->daily_count + 1;
                            
                            $rooms->daily_cache = json_encode( $cache );
                        }
                    }
                    else
                    {
                        $rooms->daily_count = 1;
                        
                        $rooms->daily_cache = json_encode( [ $member->member_id => 1 ] );
                    }
                    
                    $rooms->recache = false;
                    
                    $rooms->save();
                }
            }
            
            return $data;
        }
        catch( \Exception $exception )
        {
            \IPS\Log::log( \get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
        }
    }
    
    public function counts()
    {
        try
        {
            $client = $this->ioClient();
            
            $client->initialize();
            
            $client->emit( 'counts', [] );
            
            $client->close();
        }
        catch( \Exception $exception )
        {
            \IPS\Log::log( \get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
        }
    }
}

 

Share this comment


Link to comment
Share on other sites

i've edited your previous reply, in the spoiler you will see a line i've marked in red. place it after that one.

1 person likes this

Share this comment


Link to comment
Share on other sites
On 3/15/2017 at 9:02 PM, Michael said:

i've edited your previous reply, in the spoiler you will see a line i've marked in red. place it after that one.

Thanks Michael.

I had to abandon using my own server so this can be closed. I will need to use babble service trial in stead

Share this comment


Link to comment
Share on other sites