EzDevInfo.com

JAXL

Asynchronous, non-blocking I/O, event based PHP library for writing custom TCP/IP client and server implementations. From it's previous versions, library inherits a full blown stable support for XMPP protocol stack. In v3.0, support for HTTP protocol stack was also added. Welcome to Jaxl’s documentation! — Jaxl 3.0.1 documentation

How to IQ Query Action Protocol XMPP with JAXL PHP library

I want to send an iq query to xmpp and need a result that response from XMPP. For example:

<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>
  <ping xmlns='urn:xmpp:ping'/>
</iq>

Howerver i find all documents in http://jaxl.readthedocs.org/en/latest/users/xmpp_extensions.html and cant find the way to do that. So hope that someone can help me. Thanks


Source: (StackOverflow)

Openfire http prebinding with JAXL

I am trying to implement converse.js in my project to use Openfire chat and am prebinding the user using JAXL. Its working fine on my cloud(VPS) server. when am try to publish the same code on my client server its not working. and getting the same problem when execute the same from my localhost. not working means prebind request remains (pending) for a while and ends with 500 internal server error.

we have checked the server configuration. seems to be fine. Can any one suggest me something to how to debug this one?

here is my jaxl config code.

$client = new JAXL(array(
  'jid'=>$un,
  'pass'=>$pwd,
  'bosh_url' => 'http://xx.xx.xx.xx/http-bind',
  'log_path' => __DIR__ . '/logs',
  'log_level' => JAXL_INFO,
  'strict' => false
));

Thanks in advance
-josan

UPDATE

here is my jaxl log from my client server.

1.jaxl:180 - 2014-11-05 10:47:47 - dns srv lookup for iz25pkf9c7hz
2.jaxl:189 - 2014-11-05 10:47:47 - including bosh xep
3.jaxl_fsm:61 - 2014-11-05 10:47:47 - calling state handler 'setup' for incoming event 'start_cb'
4.jaxl_fsm:71 - 2014-11-05 10:47:47 - current state 'wait_for_stream_features'
5.xep_0206:109 - 2014-11-05 10:47:47 - posting to http://182.92.156.24/http-bind body 
6.<body xmlns="http://jabber.org/protocol/httpbind" content="text/xml; charset=utf-8" 
 to="iz25pkf9c7hz" route="xmpp:iz25pkf9c7hz:5222" secure="true" xml:lang="en" 
 xmpp:version="1.0" xmlns:xmpp="urn:xmpp:xbosh" hold="1" wait="30" rid="2280" 
 ver="1.10" from="bala101@iz25pkf9c7hz">  
</body>
7.xep_0206:132 - 2014-11-05 10:47:47 - recving for 2280
8.xep_0206:132 - 2014-11-05 10:47:48 - recving for 2280
9.xep_0206:132 - 2014-11-05 10:47:48 - recving for 2280
10.xep_0206:132 - 2014-11-05 10:47:48 - recving for 2280
.
.
.
.
58854.xep_0206:132 - 2014-11-05 10:47:48 - recving for 2280
.
.
(Its just kept on adding for 5 or 3 mins)

Source: (StackOverflow)

Advertisements

Jaxl Http Server and Client with php

Im trying to implement an Http Server with jaxl. I followed the steps on their website and installed it.

For my Http Server I created the following code:

<?php

    //SERVER

    ini_set('display_errors', 1);

    require_once __DIR__.'/../vendor/jaxl/jaxl.php';
    require_once JAXL_CWD.'/http/http_server.php';

    $http = new HTTPServer();

    function on_request($request) {
        if($request->method == 'GET') {
        $body = json_encode($request);
        $request->ok($body, array('Content-Type'=>'application:json'));
        }
        else {
        $request->not_found();
        }
    }

    function index($request) {
        $request->send_response(
            200, array('Content-Type'=>'text/html'),
            '<data><to>need this xml</to></data>'
        );
        $request->close();
    }

    function upload($request) {
    if($request->method == 'GET') {
        $request->send_response(
            200, array('Content-Type'=>'text/html'),
            '<html><head/><body><h1>Jaxl Http Server</h1><form enctype="multipart/form-data" method="POST" action=""><input type="file" name="file"/><input type="submit" value="upload"/></form></body></html>'
        );
    }
    else if($request->method == 'POST') {
        if($request->body === null && $request->expect) {
            $request->recv_body();
        }
        else {
            // got upload body, save it
            _debug("file upload complete, got ".strlen($request->body)." bytes of data");
            $request->close();
        }
    }
}


    $index = array('index', '^/$');
    $upload = array('upload', '^/upload', array('GET', 'POST'));
    $rules = array($index, $upload);
    $http->dispatch($rules);
    $http->start();
?>

I can run it in my terminal by using php index.php (I created a web folder and placed an index.php file in it). This file is runnable. If I now go to my browser and do http://localhost:8888/jaxl-server/web/upload it tells me that there is no upload page on the server which is correct but i want to see the HTML. If this works I can change the HTML to XML and use it to get information with an HTTP request. My question is, it isnt working and there is not mutch information on the internet about it, can anyone help me out? I'm I doing the right steps?


Source: (StackOverflow)

php function that sends message to XMPP server give no log and doesn't work

Im working on getting a webpage where users input a text in a form and click submit. From there it validates the input and sends it to a php function that uses JAXL 3.0 library to send the message to my XMPP server.

My problem is that when I call the JAXL function nothing just happens. it's like it can't finish the function as the next function never gets it's call. if I swap the order around the other functions gets called but it still doesn't finish the sendmessage() function.

I'm rusty/new in php and I can't get JAXL to provide a log or anything to debug where my issue is.

If anyone know how to debug this php/JAXL function properly it would be a large help.

I've searched the web around and looked at examples for JAXL but can't find my issue :/

EDIT: Tried some debugging with ECHO. I can't get a ECHO out if it's posted below my Create client. If I ECHO right above it works.

My Sendmessage function:

function sendping()
  {
    //get the form elements and store them in variables
    $ping_text=$_POST["pingtext"];

    // Config Details
    $host = 'example.com';
    $user = 'host';
    $pass = 'password';

    // Create Client
    $client = new JAXL(array(
      'log_path' => '/var/log/jaxl.log',
      'jid' => $user.'@'.$host,
      'pass' => $pass,
      'log_level' => JAXL_INFO,
      'auth_type' => 'PLAIN'
    ));

    // Add Callbacks
      $client->add_cb('on_auth_success', function() use ($host, $client, $ping_text) {
      $client->send_chat_msg($host.'/announce/online', $ping_text);
      $client->send_end_stream();

    });
    $client->add_cb('on_auth_failure', function($reason) use ($client)
    {
      $client->send_end_stream();
      _info("got on_auth_failure cb with reason: $reason");
    });
    $client->add_cb('on_disconnect', function() use ($client)
    {
      _info("got on_disconnect cb");
    });
    // Startup Client
    $client->start();

My hole .php page:

<?php
/*
Template Name: Stahp Ping
*/

require 'jaxl.php';

get_header(); ?>

<div id="hidden_div" style="display:none; margin-left:auto; margin-right:auto; margin-top:20px;
text-align:center;">
<p>Ping has been sent </p>
</div>

<div style="width:850px !important;
margin-left:auto;
margin-right:auto;
margin-top:20px;
text-align:center;" id="pingform">


<form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']);?>" method="post" name="stahpbox">
<textarea name="pingtext" rows="8" cols="60"></textarea>
<input type="submit" value="Send Ping" />
</form>

</div>

<script type="text/javascript">
 function showHide() {
   var div = document.getElementById("hidden_div");
   var pingdiv = document.getElementById("pingform");
   if (div.style.display == 'none') {
     div.style.display = '';
     pingdiv.style.display='none';
   }
   else {
     div.style.display = 'none';
     pingdiv.style.display = '';
   }
 }
</script>

<?php
function sendping()
  {
    //get the form elements and store them in variables
    $ping_text=$_POST["pingtext"];

    // Config Details
    $host = 'example.com';
    $user = 'user';
    $pass = 'password';

    // Create Client
    $client = new JAXL(array(
      'log_path' => '/var/log/jaxl.log',
      'jid' => $user.'@'.$host,
      'pass' => $pass,
      'log_level' => JAXL_INFO,
      'auth_type' => 'PLAIN'
    ));

    // Add Callbacks
      $client->add_cb('on_auth_success', function() use ($host, $client, $ping_text) {
      $client->send_chat_msg($host.'/announce/online', $ping_text);
      $client->send_end_stream();

    });
    $client->add_cb('on_auth_failure', function($reason) use ($client)
    {
      $client->send_end_stream();
      _info("got on_auth_failure cb with reason: $reason");
    });
    $client->add_cb('on_disconnect', function() use ($client)
    {
      _info("got on_disconnect cb");
    });
    // Startup Client
    $client->start();
  }

//Validation and redirection to send to jabber
// Initialize variables and set to empty strings
$pingtextERR="";
// Validate input and sanitize
if ($_SERVER['REQUEST_METHOD']== "POST") {
  $valid = true; //Your indicator for your condition, actually it depends on what you need. I am just used to this method.

  if (empty($_POST["pingtext"])) {
      $pingtextERR = "Text is required";
      $valid = false; //false
      echo "<script type='text/javascript'>alert('$pingtextERR');</script>";
  }
 //if valid then redirect
  if($valid){
  echo "<script> showHide(); </script>";
  sendping();
  }
}

?>

Source: (StackOverflow)

How to send a XMPP IQ Package to a PHP JAXL-Script?

ive a problem. Im using asmack for connecting and sending Data between Android and OpenFire.

Now i'ld like to get this data with PHP and Jaxl (which is working fine).

The problem is that i modify the sent message (to JSON and XML) and add a HEADER to the XML/JSON. This seems to work well but its not a proper solution.

Now i'm thinking about sending IQ Packages which hold the Header information already.

This is the Part in Android/Java.

      CommandIQPacket iq1 = new CustomIQPacket();
            iq1.setTo(to);
            iq1.setType(IQ.Type.GET);
            iq1.setCommand("test");
            iq1.setPriority(1);
            iq1.setJid(message.getMessage());
            iq1.setDate(new Date(System.currentTimeMillis()));
        mConnection.sendPacket(iq1);

The CustomIQPacket class extends IQ and add the required data by overriding getChildElementXML().

Sample:

public class CommandIQPacket extends IQ {


private int priority;
private String jid, command;
//some getter and setter

@Override
public CharSequence getChildElementXML() {

    StringBuilder builder = new StringBuilder("<query xmlns=\"urn:xmpp:ts\">");
    builder.append("<jid command=\"");
    builder.append(command).append("\"");
    builder.append(" date=\"");
    builder.append(date).append("\"");
    builder.append(" priority=\"");
    builder.append(priority).append("\"");
    builder.append(">");
    builder.append(jid);
    builder.append("</jid>");
    builder.append("</query>");
    return builder.toString();

}

}

Now i've my PHP CLI Script with JAXL. This looks like that.

 <?php

  // configs, stuff, etc. 

$client = new JAXL(array(
'jid' => "myopenfireuser",
'pass' => "myopenfirepass",
'bosh_url' => "http://url-to-bosh.com:7070/http-bind/",
'log_level' => JAXL_INFO,
'strict' => TRUE
    ));

$client->require_xep(array(
'0115', // Entity Capabilities
'0203', // Delayed Delivery
'0114', // jabber component protocol
'1337'
));

ive added 1337 here, which should be the XEP for parsing the IQ package.

$client->add_cb('on_chat_message', function($stanza) {
global $client;

$iq = $client->xeps['1337']->get_raw_iq_pkt();
  // some more stuff
}

Now it seems to be that $iq does not hold any rawdata. I cant access the XML which means that i cant parse the IQ Package.

The 1337 XEP looks like that.

class XEP_1337 extends XMPPXep {

public function init() {
    return array(
        'on_get_iq' => 'on_xmpp_iq'
    );
}

public function get_raw_iq_pkt() {

    $attrs = array(
        'type' => 'get',
        'from' => $this->jaxl->full_jid->to_string(),
        'to' => $this->jaxl->full_jid->domain
    );

    return $this->jaxl->get_iq_pkt(
                    $attrs, new JAXLXml('query', "ts")
    );
} 
}

I couldnt find any good tutorial about JAXL and IQ Packages. This is the only readme ive found about it (https://media.readthedocs.org/pdf/jaxl/latest/jaxl.pdf)

The sent data is for example

 <iq id='qEfml-14' to='openfirebot@openfirebot.com/Ressource' type='get'><query xmlns="ts"><jid command="test" date="Mon Jul 28 12:36:15 MESZ 2014" priority="1">...</query></iq>

the return value from openfire (jaxl) is

<iq type="error" id="NP3HP-12" from="bot..@myopenfire.com" to="maclient@ts.com/Ressource"><query xmlns="ts" action="create"><jid command="test" date="Mon Jul 28 23:04:22 MESZ 2014" priority="1">...</jid></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

OpenFire error=

     at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:283) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) 
at java.lang.Thread.run(Thread.java:701) 
2014.07.29 15:56:33 org.jivesoftware.openfire.nio.ConnectionHandler - Closing connection due to error while processing message: <iq id="769-83772" to="ts.com" from="ts.com/4140f14a" type="result"></iq> 
java.lang.NullPointerException 
at org.jivesoftware.openfire.IQRouter.route(IQRouter.java:115) 
at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:76) 
at org.jivesoftware.openfire.net.StanzaHandler.processIQ(StanzaHandler.java:330) 
at org.jivesoftware.openfire.net.ClientStanzaHandler.processIQ(ClientStanzaHandler.java:93) 
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:295) 
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:187) 
at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandler.java:181) 
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570) 
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) 
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) 
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) 
at org.apache.mina.common.IoFilterAdapter.messageReceived(IoFilterAdapter.java:80) 
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) 
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) 
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) 
at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:58) 
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:185) 
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) 
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) 
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) 
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:239) 
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:283) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) 
at java.lang.Thread.run(Thread.java:701) 

Source: (StackOverflow)

Can't send a group message - Error 400 - Modify - BadRequest

The user is online, inside the room, can listen but it cannot send any message. Why?

I am using JAXL in PHP!

XML Message:

<presence xmlns="jabber:client" id="3">
    <status>available!</status>
    <show>dnd</show>
    <priority>10</priority>
</presence>
<presence
    xmlns="jabber:client" 
    from="bot@peoplebus/jaxl#notificator" 
    to="rota_1@conference.peoplebus/bot" 
    id="4">
    <x xmlns="http://jabber.org/protocol/muc">
        <history maxstanzas="0" seconds="0"></history>
    </x>
</presence>
<message 
    xmlns="jabber:client" 
    type="groupchat" 
    to="rota_1@conference.peoplebus/bot" 
    from="bot@peoplebus/jaxl#notificator">
    <body>teste</body>
</message>

Error:

jaxl_socket_client:189 - 2014-03-07 23:09:59 - or"/></x></presence>
<presence from="rota_1@conference.peoplebus/bot" to="bot@peoplebus/jaxl#notificator" id="4">
  <x xmlns="http://jabber.org/protocol/muc#user">
    <item jid="bot@peoplebus/jaxl#notificator" affiliation="none" role="participant"/>
  </x>
</presence>
<message type="groupchat" from="rota_1@conference.peoplebus" to="bot@peoplebus/jaxl#notificator">
  <body>Esta sala permite anônimos.</body>
  <x xmlns="http://jabber.org/protocol/muc#user"><status code="100"/></x>
</message>
<message type="error" to="bot@peoplebus/jaxl#notificator" from="rota_1@conference.peoplebus/bot">
  <body>teste</body>
  <error code="400" type="modify">
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  </error>
</message>

Here is a part of debug (just with what I think that is important):

jaxl_socket_client:95 - 2014-03-07 23:09:59 - trying tcp://10.208.4.180:5222
jaxl_socket_client:104 - 2014-03-07 23:09:59 - connected to tcp://10.208.4.180:5222
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 182/182 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="peoplebus" id="4453b273" xml:lang="en" version="1.0">
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 51/719 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
jaxl_socket_client:201 - 2014-03-07 23:09:59 - sent 178/440 of data
jaxl_socket_client:202 - 2014-03-07 23:09:59 - <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" to="peoplebus#" xmlns="jabber:client" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace">
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 411/1130 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="peoplebus" id="4453b273" xml:lang="en" version="1.0"><stream:features><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>
jaxl_socket_client:201 - 2014-03-07 23:09:59 - sent 140/580 of data
jaxl_socket_client:202 - 2014-03-07 23:09:59 - <iq xmlns="jabber:client" type="set" id="1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>jaxl#notificator</resource></bind></iq>
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 149/1279 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <iq type="result" id="1" to="peoplebus/4453b273"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>bot@peoplebus/jaxl#notificator</jid></bind></iq>
jaxl_socket_client:201 - 2014-03-07 23:09:59 - sent 112/692 of data
jaxl_socket_client:202 - 2014-03-07 23:09:59 - <iq xmlns="jabber:client" type="set" id="2"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"></session></iq>
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 62/1341 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <iq type="result" id="2" to="bot@peoplebus/jaxl#notificator"/>
notificator:43 - 2014-03-07 23:09:59 - got on_auth_success cb, jid bot@peoplebus/jaxl#notificator
jaxl_exception:66 - 2014-03-07 23:09:59 - error handler called with 8, Undefined index: id, /var/www/jaxl/xmpp/xmpp_stanza.php, 81
jaxl_socket_client:201 - 2014-03-07 23:09:59 - sent 484/1176 of data
jaxl_socket_client:202 - 2014-03-07 23:09:59 - <presence xmlns="jabber:client" id="3"><status>available!</status><show>dnd</show><priority>10</priority></presence><presence xmlns="jabber:client" from="bot@peoplebus/jaxl#notificator" to="rota_1@conference.peoplebus/bot" id="4"><x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0" seconds="0"></history></x></presence><message xmlns="jabber:client" type="groupchat" to="rota_1@conference.peoplebus/bot" from="bot@peoplebus/jaxl#notificator"><body>teste</body></message>
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 168/1509 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <presence id="3" from="bot@peoplebus/jaxl#notificator" to="bot@peoplebus/jaxl#notificator"><status>available!</status><show>dnd</show><priority>10</priority></presence>
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 1024/2533 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - <presence from="pidgin@peoplebus/fbaff75c" to="bot@peoplebus/jaxl#notificator"><priority>1</priority><c xmlns="http://jabber.org/protocol/caps" node="http://pidgin.im/" hash="sha-1" ver="I22W7CegORwdbnu0ZiQwGpxr0Go="/><x xmlns="vcard-temp:x:update"><photo/></x></presence><message to="bot@peoplebus/jaxl#notificator" from="pidgin@peoplebus" id="pidgin@peoplebus__bot@peoplebus__52D8K"><event xmlns="http://jabber.org/protocol/pubsub#event"><items node="http://jabber.org/protocol/tune"><item id="4ebd50d9-2c64-4c70-9fe5-45b8cffa5fda3"><tune xmlns="http://jabber.org/protocol/tune"/></item></items></event><delay xmlns="urn:xmpp:delay" stamp="2014-03-07T22:40:10.155Z"/></message><presence to="bot@peoplebus/jaxl#notificator" from="rota_1@conference.peoplebus/pidgin"><priority>1</priority><c xmlns="http://jabber.org/protocol/caps" node="http://pidgin.im/" hash="sha-1" ver="I22W7CegORwdbnu0ZiQwGpxr0Go="/><x xmlns="http://jabber.org/protocol/muc#user"> ...
jaxl_fsm:61 - 2014-03-07 23:09:59 - calling state handler 'logged_in' for incoming event 'stanza_cb'
jaxl_fsm:71 - 2014-03-07 23:09:59 - current state 'logged_in'
jaxl_socket_client:188 - 2014-03-07 23:09:59 - read 698/3231 of data
jaxl_socket_client:189 - 2014-03-07 23:09:59 - or"/></x></presence><presence from="rota_1@conference.peoplebus/bot" to="bot@peoplebus/jaxl#notificator" id="4"><x xmlns="http://jabber.org/protocol/muc#user"><item jid="bot@peoplebus/jaxl#notificator" affiliation="none" role="participant"/></x></presence><message type="groupchat" from="rota_1@conference.peoplebus" to="bot@peoplebus/jaxl#notificator"><body>Esta sala permite anônimos.</body><x xmlns="http://jabber.org/protocol/muc#user"><status code="100"/></x></message><message type="error" to="bot@peoplebus/jaxl#notificator" from="rota_1@conference.peoplebus/bot"><body>teste</body><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></message>
jaxl_fsm:61 - 2014-03-07 23:09:59 - calling state handler 'logged_in' for incoming event 'stanza_cb'
jaxl_exception:66 - 2014-03-07 23:09:59 - error handler called with 8, Undefined index: type, /var/www/jaxl/xmpp/xmpp_stanza.php, 81

Source: (StackOverflow)

Cannot Read GCM server response using JAXL php library

I can connect to the server but cannot read the acknowledgements messages sent by the gcm server. I want to know how to retrieve the XML sent by gcm server. Here is my code :

<?php
require 'jaxl/jaxl.php';
$sender = 'sender id';
$client = new \JAXL(array(
 'jid'=>$sender,
 'pass'=>'pass',
 'auth_type'=>'PLAIN',
 'host' => 'gcm.googleapis.com',
 'port' => '5235',
 'force_tls' => true,
 'strict' => FALSE,
 'ssl' => TRUE,
 'log_level' => JAXL_DEBUG,
 'log_path'=> 'ex.txt'
  )); 

  $client->add_cb('on_message_stanza', function($msg) {
 echo 'now what!!';
 });
 $client->add_cb('on_auth_success', function() {
 echo 'it should';
 global $client;

 global $sender;
 $namespace = 'google:mobile:data';
 $arr=array("hello"=>"world");
 $json_data=json_encode($arr,JSON_UNESCAPED_SLASHES);
 $arr = array('to'=>'server','message_id'=>'123','data'=>$arr);
 $json = json_encode($arr);
 $xml = new JAXLXml('gcm',$namespace,array(),$json);
 $msg = new JAXLXml('message','',array('id'=>'123'),'');
 $msg->cnode($xml);
 $client->send($msg);
  }); 
 $client->add_cb('on_error_message',function()
 {
 global $client;
 echo 'error<br/>';
 _info('got on_error_message cb jid'.$client->full_jid->to_string());
 });

In the callback 'on_auth_success', i am sending a message to gcm server directed to my server id, it is sending a negative acknowledgement 'nack' which i can see in the log, but I don't know how to receive that in php code. The XML received by gcm as per log is :

 <message>
 <data:gcm xmlns:data="google:mobile:data">{"message_id":"123","from":"someid",
 "error_description":"","error":"BAD_REGISTRATION",
 "message_type":"nack"}</data:gcm></message>

Source: (StackOverflow)

Get data of json comming from Google Cloud Messaging

I'm trying to get some information out of my incomming messages from Google Cloud Message (GCM). Message looks like this:

{
    "category":"com.myappplication",
    "data": {
        "my_message":"this data i need",
        "my_action":"com.google.android.gcm.demo.app.ECHO_NOW"
        },
    "time_to_live"86400,
    "message_id":"5",
    "from":"ADJEKRJEKRJEKJREKRJLSDLKSJDLKJ23DSD22232320DSLKJ23"
}

I only can get the data out of the "from","message_id" and "time_to_live".

In my Php script I decode the incomming json message

    $gcm_in = json_decode(str_replace("&quot;", "\"", $stanza_in->childrens[0]->text));

    $from = $gcm_in->from;

How to get the information of my_message?


Source: (StackOverflow)

not able to connect using jaxl xmpp framework

i am trying to connect with openfire server using JAXL XMPP Library for PHP but i am falling into infinite loop, i have used strophe i am able to connect using that but not in PHP

here is my code

$client = new JAXL(array(
    'jid' => 'user1@mydomain.in',
    'pass' => 'pass@123',
   // 'host'=>'mydomain.in',
    //'port'=>'5222',
    'bosh_url' => 'http://rewire.in/http-bind',
    'log_level'=>JAXL_DEBUG,
    'log_path'=> './log/xmpp.txt',
   // 'auth_type'=>'DIGEST-MD5'
));

here is my log

jaxl:188 - 2014-03-26 16:40:58 - created pid file C:\Apache24\htdocs\mypro\JAXL/.jaxl/run/jaxl_16028.pid
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: host, C:\Apache24\htdocs\mypro\JAXL\jaxl.php, 197
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: port, C:\Apache24\htdocs\mypro\JAXL\jaxl.php, 197
jaxl:200 - 2014-03-26 16:40:58 - dns srv lookup for mydomain.in
jaxl:208 - 2014-03-26 16:40:58 - including bosh xep
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: resource, C:\Apache24\htdocs\mypro\JAXL\jaxl.php, 223
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: force_tls, C:\Apache24\htdocs\mypro\JAXL\jaxl.php, 224
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: bosh_rid, C:\Apache24\htdocs\mypro\JAXL\xep\xep_0206.php, 193
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: bosh_hold, C:\Apache24\htdocs\mypro\JAXL\xep\xep_0206.php, 194
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: bosh_wait, C:\Apache24\htdocs\mypro\JAXL\xep\xep_0206.php, 195
jaxl_fsm:61 - 2014-03-26 16:40:58 - calling state handler 'setup' for incoming event 'start_cb'
xep_0114:68 - 2014-03-26 16:40:58 - starting component handshake
jaxl_exception:66 - 2014-03-26 16:40:58 - error handler called with 8, Undefined index: id, C:\Apache24\htdocs\mypro\JAXL\xmpp\xmpp_stanza.php, 81
xep_0206:109 - 2014-03-26 16:40:58 - posting to http://mydomain.in/http-bind body <body sid="" rid="3285" xmlns="http://jabber.org/protocol/httpbind"><handshake>ba97b1cf397425a852d1316d10787b1d97b5bc85</handshake></body>
jaxl_fsm:71 - 2014-03-26 16:40:58 - current state 'wait_for_stream_features'
xep_0206:109 - 2014-03-26 16:40:58 - posting to http://mydomain.in/http-bind body <body xmlns="http://jabber.org/protocol/httpbind" content="text/xml; charset=utf-8" to="mydomain.in" route="xmpp:mydomain.in:5222" secure="true" xml:lang="en" xmpp:version="1.0" xmlns:xmpp="urn:xmpp:xbosh" hold="1" wait="30" rid="3285" ver="1.10" from="user1@mydomain.in"></body>
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285
xep_0206:132 - 2014-03-26 16:40:58 - recving for 3285

Source: (StackOverflow)

Php example using XMPPPHp or JAXL to connect Google Cloud connection server

Hi all I am trying to make CCS server for the google cloud downstream and upstream messaging. I made a server using java, it was working well before I wanted to shift it to php for my convenience.

I found out two library which is XMPPPHP and JAXL for XMPP connection.

I am trying to use JAXL first using the below code with SetTimeOut of php environment to more than 2 minutes.

  <?php
 include_once 'jaxl.php';
 $client = new JAXL(array(
 'jid'=>'<my_sender_ID>@gcm.googleapis.com',
 'pass'=>'my_API_key',
 'auth_type'=>'PLAIN',
 'host' => 'gcm.googleapis.com',
 'port' => '5235',
 'force_tls' => true
)); 
$client->start();
echo "done";
?>

Studied the issue in the below url so changed the configuration too.

Link-1

Now I am getting Fatal error: Maximum execution time of 60 seconds exceeded in /var/www/vhosts/hostname/ccs-server/jaxl/core/jaxl_logger.php on line 51

When I tried my hands on XMPPPHP , I got the below link

Link-2

And got the same error as connecting to tcp://gcm.googleapis.com failed.

I am so worried if I could I transfer the server from Java or not. Please help me out.


Source: (StackOverflow)

on_presence_stanza callback for XMPP directed presence in JAXL

I have coded an XMPP client in PHP using JAXL (along the lines of the included echobot example). The client also implements XEP-0045 (MUC) and I can join groupchats without issue. The problem is that the registered callback for presence messages only appears to get called for presence messages inside the groupchats, e.g. whenever another user enters or leaves. I would like to send my client directed presence stanzas as well (outside the chat room). As coded below, these do not fire the callback.

$client->add_cb('on_presence_stanza', function($stanza) {
    global $client, $room_full_jid, $room_full_jid2;
    _info("got on_presence_stanza....");
    //.....
});

How do I need to register the callback in order to get the client to respond to directed presence as well?


Source: (StackOverflow)