FAQ
I have half a mind to experiment with writing my own google-chat-based
instant messenger in the next year, and Go seems like a great language to
do this in. Does anyone recommend a particular library for interfacing with
google's xmpp servers?

-Steven

Search Discussions

  • Kyle Lemons at Sep 6, 2012 at 7:37 pm
    I have heard good things about libpurple for chat clients if you don't want
    to interact with the protocol. Since XMPP is XML, though, and fairly
    straightforward, you could probably.get it done with the built-in xml
    support.
    On Wed, Sep 5, 2012 at 6:59 PM, Steven Degutis wrote:

    I have half a mind to experiment with writing my own google-chat-based
    instant messenger in the next year, and Go seems like a great language to
    do this in. Does anyone recommend a particular library for interfacing with
    google's xmpp servers?

    -Steven
  • John Beisley at Sep 7, 2012 at 6:30 am
    https://github.com/mattn/go-xmpp says it was forked from an original effort
    by rsc. Never tried it myself, though.
    On 6 Sep 2012 02:59, "Steven Degutis" wrote:

    I have half a mind to experiment with writing my own google-chat-based
    instant messenger in the next year, and Go seems like a great language to
    do this in. Does anyone recommend a particular library for interfacing with
    google's xmpp servers?

    -Steven
  • Jesse McNelis at Sep 7, 2012 at 6:53 am

    On Thu, Sep 6, 2012 at 11:59 AM, Steven Degutis wrote:
    I have half a mind to experiment with writing my own google-chat-based
    instant messenger in the next year, and Go seems like a great language to do
    this in. Does anyone recommend a particular library for interfacing with
    google's xmpp servers?
    Perhaps,
    https://github.com/agl/xmpp



    --
    =====================
    http://jessta.id.au
  • Chris Jones Yar at Oct 8, 2012 at 4:44 pm
    I wrote a little library for XMPP clients:
    http://code.google.com/p/goexmpp/. Problem is, encoding/xml in Go 1 doesn't
    understand attributes with namespaces, like xml:lang. Since xml:lang in
    particular -- and other namespaced attributes in general -- appear
    prominently in XMPP, I haven't tried to make my code work since Go 0.60
    when I could work around this deficiency by using MarshalXML.

    If you want to do XMPP in Go, it seems like you have a few options: First,
    you could use cgo to write glue code to libpurple or something similar.
    Second, you could manually construct all your XML strings instead of using
    encoding/xml. Third, you could help fix Go's XML support. I was going to do
    that, but ... XML is icky.

    Chris
    On Wednesday, September 5, 2012 7:59:40 PM UTC-6, Steven Degutis wrote:

    I have half a mind to experiment with writing my own google-chat-based
    instant messenger in the next year, and Go seems like a great language to
    do this in. Does anyone recommend a particular library for interfacing with
    google's xmpp servers?

    -Steven
    --
  • Russ Cox at Oct 9, 2012 at 4:22 pm
  • Steven Degutis at Oct 9, 2012 at 2:39 pm
    Perfect! Thanks!

    -Steven
  • Steven Degutis at Oct 10, 2012 at 3:26 am
    Russ, I'm having a bit of trouble sending from this package. Every time I
    send to a user, I get an xmpp.Chat back that is identical to what I tried
    to send except with Type as "error". Following your example code
    in http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go I am
    creating a new xmpp.Chat with Remote equal to the receiving chat.Remote up
    to but not including the first "/" character, with Type as "chat" and Text
    as a string. Is this not correct?

    -Steven
  • Kyle Lemons at Oct 10, 2012 at 8:32 pm
    Can you print out the raw XML? An XMPP error should have some explanatory
    text saying what it is, though I seem to recall it not being easy to
    programatically extract.
    On Tue, Oct 9, 2012 at 8:20 PM, Steven Degutis wrote:

    Russ, I'm having a bit of trouble sending from this package. Every time I
    send to a user, I get an xmpp.Chat back that is identical to what I tried
    to send except with Type as "error". Following your example code in
    http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go I am
    creating a new xmpp.Chat with Remote equal to the receiving chat.Remote up
    to but not including the first "/" character, with Type as "chat" and Text
    as a string. Is this not correct?

    -Steven

    --

    --
  • Steven Degutis at Oct 10, 2012 at 8:36 pm
    I tried that very debugging technique but could not figure out where to
    print out the raw XML request in his xmpp library.

    -Steven

    On Wednesday, October 10, 2012 2:34:47 PM UTC-5, Kyle Lemons wrote:

    Can you print out the raw XML? An XMPP error should have some explanatory
    text saying what it is, though I seem to recall it not being easy to
    programatically extract.

    On Tue, Oct 9, 2012 at 8:20 PM, Steven Degutis <sdeg...@8thlight.com<javascript:>
    wrote:
    Russ, I'm having a bit of trouble sending from this package. Every time I
    send to a user, I get an xmpp.Chat back that is identical to what I tried
    to send except with Type as "error". Following your example code in
    http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go I am
    creating a new xmpp.Chat with Remote equal to the receiving chat.Remote up
    to but not including the first "/" character, with Type as "chat" and Text
    as a string. Is this not correct?

    -Steven

    --

    --
  • Kyle Lemons at Oct 10, 2012 at 8:28 pm
    I'd inject a multiwriter / teereader in between the connection and the xml
    encoder/decoder, with the second stream going to stdout.
    On Wed, Oct 10, 2012 at 12:40 PM, Steven Degutis wrote:

    I tried that very debugging technique but could not figure out where to
    print out the raw XML request in his xmpp library.

    -Steven

    On Wednesday, October 10, 2012 2:34:47 PM UTC-5, Kyle Lemons wrote:

    Can you print out the raw XML? An XMPP error should have some explanatory
    text saying what it is, though I seem to recall it not being easy to
    programatically extract.
    On Tue, Oct 9, 2012 at 8:20 PM, Steven Degutis wrote:

    Russ, I'm having a bit of trouble sending from this package. Every time
    I send to a user, I get an xmpp.Chat back that is identical to what I tried
    to send except with Type as "error". Following your example code in
    http://code.google.com/p/**rsc/source/browse/google/acme/**Chat/main.go<http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go>I am creating a new xmpp.Chat with Remote equal to the receiving
    chat.Remote up to but not including the first "/" character, with Type as
    "chat" and Text as a string. Is this not correct?

    -Steven

    --

    --
    --
  • Steven Degutis at Oct 10, 2012 at 8:47 pm
    Oh I see now. When I send a response chat back to whoever sends me a chat
    (like an echo server), via client.Send(xmpp.Chat{Remote:
    incomingChat.Remote, Type: "chat", Text: "foobla"}) then I get this XML
    response back:

    <message to="" from="ignore.my@real.email.com" type="error"
    xml:lang="en"><body>foobla</body><error code="400"
    type="modify"><jid-malformed
    xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text
    xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Malformed JID '': domain is
    empty</text></error></message>

    But as far as I can tell the sample code Russ posted previously does this
    same thing. I've also tried not deleting everything including and after the
    first slash from the incoming name, but I get basically the same response
    back, with definitely the same error:

    <message to="" from="ignore.my@real.email.com/Steven’s MA48440E8"
    type="error" xml:lang="en"><body>foobla</body><error code="400"
    type="modify"><jid-malformed
    xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text
    xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Malformed JID '': domain is
    empty</text></error></message>

    I'm just confused because as far as I can tell I'm doing the same thing
    Russ's sample code is doing
    at http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go

    -Steven

    On Wednesday, October 10, 2012 3:00:47 PM UTC-5, Kyle Lemons wrote:

    I'd inject a multiwriter / teereader in between the connection and the xml
    encoder/decoder, with the second stream going to stdout.

    On Wed, Oct 10, 2012 at 12:40 PM, Steven Degutis <sdeg...@8thlight.com<javascript:>
    wrote:
    I tried that very debugging technique but could not figure out where to
    print out the raw XML request in his xmpp library.

    -Steven

    On Wednesday, October 10, 2012 2:34:47 PM UTC-5, Kyle Lemons wrote:

    Can you print out the raw XML? An XMPP error should have some
    explanatory text saying what it is, though I seem to recall it not being
    easy to programatically extract.
    On Tue, Oct 9, 2012 at 8:20 PM, Steven Degutis wrote:

    Russ, I'm having a bit of trouble sending from this package. Every time
    I send to a user, I get an xmpp.Chat back that is identical to what I tried
    to send except with Type as "error". Following your example code in
    http://code.google.com/p/**rsc/source/browse/google/acme/**Chat/main.go<http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go>I am creating a new xmpp.Chat with Remote equal to the receiving
    chat.Remote up to but not including the first "/" character, with Type as
    "chat" and Text as a string. Is this not correct?

    -Steven

    --

    --
    --
  • PeteT at Oct 10, 2012 at 9:12 pm

    I'm just confused because as far as I can tell I'm doing the same thing
    Russ's sample code is doing at
    http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go

    To help find the problem, I recommend logging what you are writing to the
    server in addition to what you are reading.

    --
  • Steven Degutis at Oct 11, 2012 at 10:24 am
    Ah, I see. Turns out I'm sending:

    <message to='a.real@email.com/Steven’s MB694B29E' from='' type='chat'
    xml:lang='en'><body>foobla</body></message>

    This seems to indicate that my Client object actually has an empty jid
    field, which appears to be a bug in Russ's xmpp library, I'm guessing
    somewhere around http://code.google.com/p/rsc/source/browse/xmpp/xmpp.go#213

    I'll dig into it further, although I'm pretty confused by this code and not
    a very smart programmer so I'm not sure how much progress I can make. Russ
    if you're reading this, do you have any tips as to what could be causing it
    to get a wrong jid? I clearly see that in my response I'm getting this back:

    <iq id="x" type="result"><bind
    xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>a.real@email.com/23F41190</jid></bind></iq>

    And when I print out the value of the iq object right after decoding it,
    sticking the printing code at line 214, I get this:

    xmpp.clientIQ{XMLName:xml.Name{Space:"jabber:client", Local:"iq"}, From:"",
    Id:"", To:"", Type:"", Error:xmpp.clientError{XMLName:xml.Name{Space:"",
    Local:""}, Code:"", Type:"", Any:xml.Name{Space:"", Local:""}, Text:""},
    Bind:xmpp.bindBind{XMLName:xml.Name{Space:"urn:ietf:params:xml:ns:xmpp-bind",
    Local:"bind"}, Resource:"", Jid:""},
    Query:xmpp.clientQuery{Item:[]xmpp.rosterItem(nil)}}

    And I believe it's using the above line of XML because on line 207 right
    before decoding the XML into the iq object, I'm printing "Starting to
    decode IQ!" and seeing it printed right before the above <iq> element.

    -Steven

    On Wednesday, October 10, 2012 4:12:42 PM UTC-5, PeteT wrote:

    I'm just confused because as far as I can tell I'm doing the same thing

    To help find the problem, I recommend logging what you are writing to the
    server in addition to what you are reading.
    --
  • Kyle Lemons at Oct 11, 2012 at 9:38 pm

    On Thu, Oct 11, 2012 at 3:24 AM, Steven Degutis wrote:

    Ah, I see. Turns out I'm sending:

    <message to='a.real@email.com/Steven’s MB694B29E' from='' type='chat'
    xml:lang='en'><body>foobla</body></message>
    I can't tell if this is what you mean, but to me the 's looks like it's
    what's killing that line.

    This seems to indicate that my Client object actually has an empty jid
    field, which appears to be a bug in Russ's xmpp library, I'm guessing
    somewhere around
    http://code.google.com/p/rsc/source/browse/xmpp/xmpp.go#213

    I'll dig into it further, although I'm pretty confused by this code and
    not a very smart programmer so I'm not sure how much progress I can make.
    Russ if you're reading this, do you have any tips as to what could be
    causing it to get a wrong jid? I clearly see that in my response I'm
    getting this back:

    <iq id="x" type="result"><bind
    xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>a.real@email.com/23F41190
    </jid></bind></iq>

    And when I print out the value of the iq object right after decoding it,
    sticking the printing code at line 214, I get this:

    xmpp.clientIQ{XMLName:xml.Name{Space:"jabber:client", Local:"iq"},
    From:"", Id:"", To:"", Type:"",
    Error:xmpp.clientError{XMLName:xml.Name{Space:"", Local:""}, Code:"",
    Type:"", Any:xml.Name{Space:"", Local:""}, Text:""},
    Bind:xmpp.bindBind{XMLName:xml.Name{Space:"urn:ietf:params:xml:ns:xmpp-bind",
    Local:"bind"}, Resource:"", Jid:""},
    Query:xmpp.clientQuery{Item:[]xmpp.rosterItem(nil)}}

    And I believe it's using the above line of XML because on line 207 right
    before decoding the XML into the iq object, I'm printing "Starting to
    decode IQ!" and seeing it printed right before the above <iq> element.

    -Steven

    On Wednesday, October 10, 2012 4:12:42 PM UTC-5, PeteT wrote:

    I'm just confused because as far as I can tell I'm doing the same thing
    Russ's sample code is doing at http://code.google.com/p/**
    rsc/source/browse/google/acme/**Chat/main.go<http://code.google.com/p/rsc/source/browse/google/acme/Chat/main.go>

    To help find the problem, I recommend logging what you are writing to the
    server in addition to what you are reading.
    --

    --
  • Russ Cox at Oct 16, 2012 at 6:11 pm
    Sorry, I have been without time to read golang-nuts for a week or so.
    It seems entirely possible that I screwed up the jid when I updated
    the code to work with Go 1 [sic]. My suggestion would be to diff my
    code against mattn's code on github. I prefer the API of my package
    but I haven't used it recently. Mattn's code may be semantically
    better as far as XMPP protocol details.

    Russ

    --
  • PeteT at Oct 10, 2012 at 8:48 pm

    I tried that very debugging technique but could not figure out where to
    print out the raw XML request in his xmpp library.

    You can modify the code and wedge a read logger
    (http://golang.org/pkg/testing/iotest/#NewReadLogger) between the XML
    reader and the connection.

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 6, '12 at 1:59a
activeOct 16, '12 at 6:11p
posts17
users7
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase