[jdev] Simple JavaScript XMPP client example

Chris Fortmüller chritsche at gmail.com
Thu Sep 4 22:05:13 UTC 2014


Ok, so I have experimented a bit more, and as Steven said, if I host the
code on a server, the code works, but if I just access it locally, the code
does not work. I still don't quite understand why. If I access the code
locally from my machine, and then try to connect to a server on the web,
the domain where the code is hosted (my local machine) and the server
domain are different, but this is also the case if I host the code on a
server and try to connect to a server in another domain, which does work.
So I don't quite understand what is the problem then when I access the code
locally


On Thu, Sep 4, 2014 at 8:16 PM, Chris Fortmüller <chritsche at gmail.com>
wrote:

> So, I bought the book, but cant get the first example in chapter 3 to
> connect to an external public xmpp server I registered with (
> alpha-labs.net). Anyone any idea where I can address this? The book's
> forum at
> http://p2p.wrox.com/book-professional-xmpp-programming-javascript-jquery-542/
> does not seem to be very frequented.
>
>
> On Wed, Sep 3, 2014 at 5:48 PM, Hund, Johannes <johannes.hund at siemens.com>
> wrote:
>
>>  Hi,
>>
>>
>>
>> just some debugging tips:
>>
>> open the dev console of the browser you use, you’ll see the bosh
>> requests/responses.
>>
>> Also, you can provide a log function for stophe resp. uncomment the lines
>> in the example.
>>
>>
>>
>> Btw: Openfire allows you confige the CORS header and it’s * by default.
>>
>>
>>
>> Best’
>>
>> Johannes
>>
>>
>>
>> *Von:* JDev [mailto:jdev-bounces at jabber.org] *Im Auftrag von *Chris
>> Fortmüller
>> *Gesendet:* Dienstag, 2. September 2014 18:43
>>
>> *An:* Jabber/XMPP software development list
>> *Betreff:* Re: [jdev] Simple JavaScript XMPP client example
>>
>>
>>
>> Just bought Metajack's book, along with XMPP: The Definitive Guide:
>> Building Real-Time Applicatins with Jabber Technologies
>>
>>
>>
>> On Tue, Sep 2, 2014 at 6:13 PM, Chris Fortmüller <chritsche at gmail.com>
>> wrote:
>>
>> @Kirk, thanks for the suggestions, will have a look.
>>
>>
>>
>> @Steven: The purpose of all this testing is that I hope on writing a
>> little instant messenger app for android, which will have local
>> html/javascript pages within the application package, which are supposed to
>> host the xmpp code. So following your post, under this scenario, I will
>> also face CORS issues? Will need to investigate this further
>>
>>
>>
>> Thanks to all!
>>
>>
>>
>> Chris
>>
>>
>>
>> On Tue, Sep 2, 2014 at 5:44 PM, Kirk Bateman <kirk.bateman at gmail.com>
>> wrote:
>>
>> Metajack's book (Jack Moffitt) has good setup and examples for strophe
>> and bosh proxying
>>
>>
>>
>> "Professional XMPP Programming with Javascript and jquery"
>>
>>
>>
>> There are probably some bits of help on his blog too (check the archive),
>> http://metajack.im
>>
>>
>>
>> Cheers
>>
>>
>>
>> Kirk Bateman
>>
>>
>>
>> On 2 September 2014 16:41, Steven Lloyd Watkin <lloyd at evilprofessor.co.uk>
>> wrote:
>>
>> Generally its easer to serve your site on https://site.com and proxy
>> bosh at something like site.com/http-bind/. Otherwise you'll hit CORS
>> issues. So in summary, yes you are correct ;)
>>
>>
>>   _____________________________________________________
>>
>> Steven Lloyd Watkin
>>
>> Software Engineer
>>
>> PHP ::: Java ::: Ruby ::: Node.js ::: XMPP
>> lloyd at evilprofessor.co.uk (email+jid) ::: http://www.evilprofessor.co.uk
>> Facebook / Twitter / Flickr: lloydwatkin
>>
>> Organiser of WORLD RECORD breaking charity event:
>>
>> Scuba Santas ::: http://www.scuba-santas.co.uk
>> Supporting the RNLI & DDRC - 15th December 2013 - NDAC, Chepstow
>>
>>
>>
>> On 2 September 2014 16:34, Chris Fortmüller <chritsche at gmail.com> wrote:
>>
>> @Christian: yes, I tried this, no change.
>>
>>
>>
>> @Stefan: I am just opening the local html file in chrome,
>> i.e.file:///C:/Users/B/Desktop/strophejs-master/strophejs-master/examples/echobot.html.
>>
>>
>>
>> Your saying I need to access it somehow like
>> http://localhost:5280/myfile.html?
>>
>>
>>
>>
>>
>> On Tue, Sep 2, 2014 at 5:24 PM, Stefan Strigler <
>> stefan.strigler at gmail.com> wrote:
>>
>> Where are you loading your html file from? This needs to be served from
>> the same host and port than your service (i.e. localhost:5280).
>> Alternatively you'd need to supply a crossdomain.xml that allows your
>> html/javascript to connect to any host/port.
>>
>>
>>
>> .Stefan
>>
>>
>>
>> 2014-09-01 21:54 GMT+02:00 Chris Fortmüller <chritsche at gmail.com>:
>>
>>
>>
>> Thanks to all for your answers.
>>
>>
>>
>> Johannes, I have tried the echobot example, changing var BOSH_SERVICE to '
>> http://localhost:5280/http-bind', where my BOSH service is up and
>> running.
>>
>>
>>
>> When I try to connect in echobot.html, I just get
>>
>>
>>
>> Strophe is connecting.
>>
>> Strophe failed to connect.
>>
>> Strophe is disconnected.
>>
>> Strophe is connecting.
>>
>> Strophe failed to connect.
>>
>> Strophe is disconnected.
>>
>> Strophe is connecting.
>>
>> Strophe failed to connect.
>>
>> Strophe is disconnected.
>>
>> Strophe is connecting.
>>
>> Strophe failed to connect.
>>
>> Strophe is disconnected.
>>
>>
>>
>> So, a bunch of failed attempts. Not sure what the issue is
>>
>>
>>
>> On Mon, Sep 1, 2014 at 4:44 PM, Steven Lloyd Watkin <
>> lloyd at evilprofessor.co.uk> wrote:
>>
>> There's also an older version of node-xmpp which can be browserified and
>> run directly in the browser. Version 1.0.0 is getting closer to release (it
>> is available through npm) but currently browserify is broken - probably my
>> fault.
>>
>>
>>
>> Lloyd
>>
>>
>>   _____________________________________________________
>>
>> Steven Lloyd Watkin
>>
>> Software Engineer
>>
>> PHP ::: Java ::: Ruby ::: Node.js ::: XMPP
>> lloyd at evilprofessor.co.uk (email+jid) ::: http://www.evilprofessor.co.uk
>> Facebook / Twitter / Flickr: lloydwatkin
>>
>> Organiser of WORLD RECORD breaking charity event:
>>
>> Scuba Santas ::: http://www.scuba-santas.co.uk
>> Supporting the RNLI & DDRC - 15th December 2013 - NDAC, Chepstow
>>
>>
>>
>> On 1 September 2014 14:51, Hund, Johannes <johannes.hund at siemens.com>
>> wrote:
>>
>>    Hi Christopher,
>>
>>
>>
>> looks like a sasl  Problem.
>>
>>
>>
>> I recently whipped something up using strophe.js and found this example
>> quite useful:
>>
>> https://github.com/strophe/strophejs/blob/master/examples/echobot.js
>>
>>
>>
>> Worked out of the box with openfire.
>>
>>
>>
>> Cheers,
>>
>> Johannes
>>
>>
>>
>>
>>
>> *Von:* JDev [mailto:jdev-bounces at jabber.org] *Im Auftrag von *Christopher
>> Fortmüller
>> *Gesendet:* Montag, 1. September 2014 15:02
>> *An:* jdev at jabber.org
>> *Betreff:* [jdev] Simple JavaScript XMPP client example
>>
>>
>>
>> Hi all,
>>
>>
>>
>> I am running an ejabberd server for testing purposes.
>>
>> I am now looking for a very basic example of a working JavaScript/html
>> client to log in to this server.
>>
>>
>>
>> I have tried several JavaScript libraries so far, unfortunately, to no
>> avail. Would also appreciate input on my post on stackoverflow, if anyone
>> has any:
>> http://stackoverflow.com/questions/25601350/ejabberd-authentication-configuration-for-plain-or-md5-digest-for-javascript-con
>>
>>
>>
>> I tried connecting with jQueryXmpp in that case.
>>
>>
>>
>> Thanks for any and all help,
>>
>>
>>
>> Cheers,
>>
>>
>>
>> Chris
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>>
>>
>>
>> _______________________________________________
>> JDev mailing list
>> Info: http://mail.jabber.org/mailman/listinfo/jdev
>> Unsubscribe: JDev-unsubscribe at jabber.org
>> _______________________________________________
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.jabber.org/jdev/attachments/20140905/1fce4e72/attachment-0001.html>


More information about the JDev mailing list