Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 996167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:50:09+00:00 2026-05-16T06:50:09+00:00

I am working with Ejabberd and Orbited and I am having a few issues

  • 0

I am working with Ejabberd and Orbited and I am having a few issues with my JavaScript callback functions not being called. The following is my JavaScript file where the TCPSocket connection happens and I have two callback functions namely

onSocketConnect: which is called when the Orbited established connection with port 5222 of the XMPP server and

onLoginSuccess: which is called on the successful completion of the xmpp_client.login function

The problem I’m facing is the connection happens successfully but my callbacks get called only when I’m using FireFox and not while using Safari or Chrome. I’m totally clueless about what is causing this problem but I’m sure that the method xmpp_client.login does get called because the user is logged in and is displayed as online in the ejabberd admin console.

TCPSocket = Orbited.TCPSocket; 
Orbited.settings.port = 8000;
Orbited.settings.hostname = 'localhost';

document.domain = document.domain; 

<script src='http://localhost:8000/static/protocols/xmpp/xmpp.js'></script>

//xmpp.js file is included after this which is available with the Orbited. I have not included the code here.

<% if current_user %>
<script>
    notifier = '    ';
    user = "<%= current_user.jabber_id %>";
    alert(user);
    password = '123456';
    domain = XMPPDOMAIN;

/*  function onLoginSuccess(){
        $('.status').html("Connected and Logged In");
        xmpp_client.set_presence('available');
    } */

    var onLoginSuccess = function(){
        $('.status').html("Connected and Logged In");

    }
    function onLoginFailure(){
        alert('User could not be logged in');
    }
    function connectSuccess(){
        $('.status').html("Connection Successful.");
    }

    function connectFailure(){
        $('.status').html("Connection Failed!");
    }

    function onSetupNotification(){}

    xmpp_client = new XMPPClient();
    xmpp_client.connect('localhost',5222);

    xmpp_client.onPresence = function(ntype, from) {
        alert('Presence message' + ntype + ' From :' + from)

    }

    xmpp_client.onSocketConnect = function(domain, connectSuccess, connectFailure){

        var domain = XMPPDOMAIN;
        $('.status').html('Connected');
        alert(user);
        if(domain)
        {
            xmpp_client.connectServer(domain, connectSuccess, connectFailure);
            xmpp_client.login(user, password, onLoginSuccess, onLoginFailure);
            xmpp_client.set_presence('available');

        }

    }

    function send_message(id, msg){

        var j_id =  id + '@' + 'siddharth-ravichandrans-macbook-pro.local';
        alert('jid_id' + j_id);
        var status = xmpp_client.msg(j_id, msg);
        alert(status);
    }

    xmpp_client.onMessage = function(jid, username, text) {
        alert('message-recieved');
        if ( $('.discussion-area').length > 0 ){
            $('.discussion-area').append('<div class=\'new-message\'>' + text + '</div>');
            return false;
        }
    }

/*      self.login = function(nick, pass, s, f) {
    conn.onread = setUser;
    success = s;
    failure = f;
    user = nick;
    bare_jid = nick + "@" + domain;
    full_jid = bare_jid + "/Orbited";
    self.send(construct(LOGIN, [user, pass]));
    }

    self.set_presence = function(status, status_msg) {
    self.send(EXT_PRESENCE[0] + full_jid + EXT_PRESENCE[1] + room_jid + EXT_PRESENCE[3] + status + EXT_PRESENCE[4] + status_msg + EXT_PRESENCE[5]);
    }
*/
 </script>
<% end %>

This is part of the xmpp.js which I got when I installed orbited and in order to test if my requests were actually reaching I added an alert in the login method as follows


...
...

    self.login = function(nick, pass, s, f) {
        conn.onread = setUser;
        success = s;
        failure = f;
        user = nick;
        bare_jid = nick + "@" + domain;
        full_jid = bare_jid + "/Orbited";
        self.send(construct(LOGIN, [user, pass]));
        alert("bazingaa");
    }

    self.connectServer = function(d, s, f) {
        success = s;
        failure = f;
        doma
...
...

Now I have no clue how this got my callbacks and would really appreciate some help on this.

Thanks

Actually I find that removing the xmpp_client.set_presence and moving it to the onLoginSuccess is what seems to have done the trick. The minute I add the set_presence method after the login method call the functionality fails in chrome. So why would that prevent it from invoking the callback on successful login?



    var onLoginSuccess = function(){
        $('.status').html("Connected and Logged In");
        xmpp_client.set_presence('available');
    }

    xmpp_client.onSocketConnect = function(domain, connectSuccess, connectFailure){

        var d = "";
        $('.status').html('Connected'); 

            xmpp_client.connectServer(d, connectSuccess, connectFailure);
            xmpp_client.login(user, password, onLoginSuccess, onLoginFailure);
            //xmpp_client.set_presence('available');



    }


Help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:50:09+00:00Added an answer on May 16, 2026 at 6:50 am

    I think your problem is related to the Same Origin Policy for Javascript

    https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript

    I’m sure the Safari/Chrome Web Inspector (with Javascript enabled) will verify this in the javascript console

    Modern browsers (ie. not Internet Explorer!) get around this issue by implementing Cross-Origin Resource Sharing. But then your Javascript XMPP client library has to implement CORS too

    http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/

    I’m not familiar with Orbited but I have done this type of browser XMPP connections using the Strophejs library and ejabberd’s XMPP BOSH connection manager

    To get around the Same Origin policy across all browsers you need to employ a proxy

    http://flxhr.flensed.com/ (client-side proxy library)

    If using apache you can employ a server-side proxy with the ProxyPass directive under the mod_proxy module

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working on a somewhat complex page for configuring customers at work. The setup is
Working on a project that parses a log of events, and then updates a
Working with python interactively, it's sometimes necessary to display a result which is some
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working with TCL and I'd like to implement something like the Strategy Pattern .
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
Working on a project where a sequential set of methods must be run every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.