p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional XMPP Programming with JavaScript and jQuery (http://p2p.wrox.com/forumdisplay.php?f=542)
-   -   Can't connect to bosh.metajack nor my own server :( (http://p2p.wrox.com/showthread.php?t=80388)

Iftah August 5th, 2010 08:26 AM

Can't connect to bosh.metajack nor my own server :(

I read ~75% of the book and think its an excellent book, very clear yet powerful stuff. Thank you Jack for writing this book!

However today I tried running the examples and failed miserably :(
I am running my own XMPP server (Openfire). It has an http binding feature, and emite (GWT XMPP lib+client) connect to it just fine.

I tried chapter 4 example (Peek) but it doesn't connect. I am pretty new to javascript and web programming in general, but looks to me like bosh.metajack.im:5280/xmpp-httpbind doesn't reply. It replies fine to the browser.

I see there is another thread with this issue and its unresolved there, so I figured instead of connecting to bosh.metajack I'd connect to my server directly.
I changed the connection url to my machine, and I get an error from flXHR (seen thanks to firebug)
flXHR::onreadystatechange(): Error, An error occurred in the handler function. (xml.tagName is undefined)

The error message is cryptic and didn't give me much to work on, but I figured I don't need flXHR because I can host the webpage from the same machine that runs the xmpp server. So I removed the flXHR imports from the html.

Now I don't have any errors in firebug, but it still doesn't connect. Looking at the Net tab, under XHR I see 3 attempts to http bind, all have status "200 aborted".

What am I doing wrong?

I am using
JID Iftah@ (I tried also just Iftah)
Server (the openfire http binding)

as I said I can connect using another XMPP javascript client (emite).

thanks in advance,

Iftah August 9th, 2010 06:50 AM

Ok turns out I misunderstood the javascript Same Origin Policy. It does not apply just to the server IP or domain, but also to the port.

I was running the javascript files with a simple python web server on one port and the xmpp server on the same machine but different port (of course).

The way to set it up is to make the web server proxy the requests of a certain url to the other server. As described here http://www.malcollier.com/?p=14 or here http://www.pheedcontent.com/click.ph...cc834be5b76f77.
I'll setup apache webserver and set it and see if I can finally play with the book examples with my own server.

When I tried running the Emite chat I did not run it with the python webserver but from within eclipse, and I guess they had their project setup to forward the url on the server side.

davidceline March 31st, 2013 05:50 PM

xml.tagName is undefined
I had the same problem running the example in Chapter 4 (peek.html)
I was connecting to googletalk servers.
I discovered that googeltalk sends back a space character on a regular basis, and the first one was sent before connection. This caused pretty_xml function to choke because the xml passed to the function did not have a tagName property.

I fixed it by checking for the tagName property, and just returning if it did not exist:

            if (typeof(xml.tagName) == 'undefined' ) {
                    return "";

metajack March 31st, 2013 09:50 PM

A better fix would be to check the node type and ignore anything but element nodes.

Feel free to submit this via pull request on github, or just file a bug:

All times are GMT -4. The time now is 03:22 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.