Handle see-other-host in smack - xmpp

I'm trying to use smack in order to connect to Microsoft's Xmpp Msn api. Last april they made a change in their implementation which forces clients to implement the "see-other-host" xmpp specification. When I try to connect to "xmpp.messenger.live.com" I get
stream:error (see-other-host)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:260)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
I'm debugging and I can see the raw received packets
<stream:stream from="messenger.live.com" version="1.0" id="59784" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
<stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required /></starttls></stream:features>
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<stream:stream from="messenger.live.com" version="1.0" id="59785" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><see-other-host xmlns="urn:ietf:params:xml:ns:xmpp-streams">BY2MSG3020517.gateway.edge.messenge r.live.com</see-other-host></stream:error>
But I'm unable to find a way in order to intercept and handle that redirect.
Has anybody done this? Any help would be appreciated. Thanks.
BTW I've already post this on smack forums but got no reply, hope this is isn't considered cross-posting.

This background may help in fixing the problem
The see-other-host stream error redirects a client to another server. In the case of Messenger, it's intended to allow clients to cleanly switch to another server should their current server go out of service, or to connect to another server for load-balancing purposes.
Based on Sample Java Codes that uses SAMCK there are two problems:
The registered connection listeners don't receive notification of the exception
there's no way to access the text element of a stream error from XMPPException
Handling the redirection internally would be the friendliest solution, but notifying the client of the new server would at least allow clients to make a new connection without user intervention.

I added see-other-host support to SMACK API for try. Now i can get see-other-host address as an Exception. For Example when i try to connect to messenger.live.com address i'm successfully getting see-other-host : BAYMSG1020118.gateway.messenger.live.com .
Then i try to connect BAYMSG1020118.gateway.messenger.live.com , i'm getting see-other-host again with different address: BY2MSG4010610.gateway.messenger.live.com
Finally when i try to connect BY2MSG4010610.gateway.messenger.live.com , i'm getting this exception :
No response from the server.:
java.lang.NullPointerException
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:73)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:211)
at org.jivesoftware.smack.Connection.login(Connection.java:348)
at com.ms.wlm.XmppClient.logIn(XmppClient.java:161)
at com.ms.wlm.Program.main(Program.java:62)
I'll share this result with Smack guys also. If you want, I can send to you the capture of our xmpp traffic via email.
Best Regards,
Alper Ozdamar

I finally found a solution for this issue by changing hostname from messenger.live.com to 64.4.61.217 in ConnectionConfiguration constructor as shown in the code below:
I got this IP by executing (nslookup messenger.live.com) in Dos Command Prompt then I got an Address which I have used in the ConnectionConfiguration.
SASLAuthentication.registerSASLMechanism("X-MESSENGER-OAUTH2",
XMessengerOAuth2.class);
SASLAuthentication.supportSASLMechanism("X-MESSENGER-OAUTH2");
ConnectionConfiguration config = new ConnectionConfiguration("64.4.61.217", 5222, "messenger.live.com");
config.setRosterLoadedAtLogin(true);
config.setSASLAuthenticationEnabled(true);
connection = new XMPPConnection(config);
connection.connect();
connection.login(username, password);
Hope this would help,,,

Related

Blocking user using privacy list in ejabberd returns "not-well-formed"

I want to block other user in ejabberd on basis of jid. I am trying to send iq stanza through send_stanza_c2s command. Like :-
send_stanza_c2s admin localhost Smack "<iq from='admin#localhost/Smack' type='set' id='msg1'><query xmlns="jabber:iq:privacy"><list name="blocked"><item type="jid" value="jack10#localhost" action="deny" order="3"/><message/></item></list></query></iq>"
But it is giving me error.
Error: {4,<<"not well-formed (invalid token)">>}
Please help me with this.
Also guide me on if blocking user is achievable only through privacy lists (XEP-0016).
The IQ request stanza you send to the server is not well formed, I.e. invalid. If you used Smack's API for privacy lists then you should report this as bug.

Facebook Chat (XMPP) XEP 0080 support

I have being checking out using a prototype test program the capabilities of the XMPP Facebook Chat, X-FACEBOOK. It worked great using a geoloc message XEP 0080 with Gmail servers, but when i try to send the same XML structure through the X-FACEBOOK, it trims the message and removes the GeoLoc node.
I wanted to ask if someone knows if its possible to send XEP 0080 messages in X-FACEBOOK and if so what structure should I use so the Facebook Chat XMPP Server won't trim the GeoLoc info.
Sent XMPP geoloc message:
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="http://jabber.org/protocol/geoloc">
<item id="">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
</item>
</items>
</event>
<body>
</body>
Received message by client:
<message xmlns="jabber:client" from="-1177157556#chat.facebook.com" to="" type="chat">
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body></body>
</message>
Any solution or opinion will be greatly appreciated.
Well, changed the XML to resemble the one you posted, without the pub sub, and still the same problem, the message received in the recipient lacks all the namespaces under the GeoLoc node, which I think is a result of the Server not supporting that format. I can try and use the IQ subscriber option, thing is that I prefer to find a solution on which I can directly send the info to a user.
If there is a possibility, even a small one in which i may be able to send information regarding GeoLoc from User A to User B in Facebook Server it may be of great help, if not well i guess i will have to accept it.
Thx for the help BTW.
When I was testing facebook XMPP connection, it did not support almost any extensions and blocked any custom tags on server. It was able to send basic presences, basic messages, vcards and that was about all it could do.
Pubsub events should be sent to services. Modern XMPP servers also support PEP extension and you can send pubsub to servers itself. In other cases, use message with target user as Robin have advised.
I do not think facebook has any server with pubsub. Also i think it still filters any unsupported namespaces. Feel free to prove me I am wrong, it is more than year since I last tested it.
These are not the same message.
The received message is simply an indicator of the users chat state, as defined in XEP-0085 and has no direct relationship to the message you sent. That doesn't mean that the first didn't potentially trigger the second, whatever library you are using may have sent the chatstate as well when you sent the message. This type of message is commonly used in chat clients to indicate that someone you are chatting with is typing a message.
The problem is probably that the message you are sending is in fact a PEP message. This is meant to be sent by the PEP service in the server, not from a client. I don't know if Facebook supports PEP or not, but I would guess that it is being filtered out due to your incorrect usage of a known namespace. PEP or Pubsub are the recommended ways of publishing geolocation information, but to utilize those you have to send an IQ packet to the service, not a message to the other client.
Try this instead (Not saying it will work, but at least the pubsub stuff is stripped):
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
<body>
</body>
</message>
I want to second Pihhan. It seems like the Facebook XMPP servers restructure messages to contain only the message body, date, and timestamp. I think they do that to keep it identical to their comment graph objects.
It is annoying, but I suspect it is deliberate. After all, their Graph is the main issue, not XMPP.

Authentication Error in username and password

Ha ii everybody ,i am doing a reader application in iphone ,my need is to sync text to google-doc and download it when even wanted,i finished it,but my problem is when i put the username and password to google-doc for authentication it shows an error message GData error Service Forbiddon…."403.4 SSL required"(403),whats the meaning of this message?how can i solve this,if anybody knows how to solve this issue please help me as soon as possible.
Thanks in advance.
Without knowing how you exactly send the request the message indicates that you have to use SSL and thus https to access the service instead of http. Depending on how you query the service this may be as simple as changing the URL or quite complicated.
I have solved my problem .we have to put https instead of http for the url.simple.Need to put (s) in http.every thing works fine for me now.
Thanks .

I have integrated yahoo into iphone app but i am getting error:400 bad request

I have to access social information for the logged-in user.i have used following link. http://developer.yahoo.com/social/sdk/objectivec
i have used send request method to get user information.
but i am getting following error message
<
?xml version='1.0' encoding='utf-8'?>
<error xmlns='http://yahooapis.com/v1/base.rng'
xml:lang='en'>
<description>400 Bad Request</description>
<detail>400 Error : syntax error, unexpected &apos;(&apos; at "*(*null)"
can any one help me?
thank you in advance.
The Yahoo Web server (running the Web site) thinks that the data stream sent by the client (e.g. your Web browser or our CheckUpDown robot) was 'malformed' i.e. did not respect the HTTP protocol completely. So the Web server was unable to understand the request and process it. so make sure you are sending the well structured request.
Based on your commented:
http://nullinfo.wordpress.com/oauth-yahoo/
http://developer.yahoo.com/oauth/guide/oauth-make-request.html
You should understand how to make request with oauth, first read that and later if you could not succeed, ask again.

why do i get this error "Unknown host http:80"?

i'm developing an application for blackbery, i'm displaying a webpage using Eclipse and net.rim.device.api.browser.field.* api when i click a submit buttom in a form i get this error "Unknown host http:80", can anyone helpme?
Don't know anything about Blackberries, but it looks like you're entering a URL where your program is only expecting a host name.
It sounds like form on the web page is not properly set up, causing the post action to post to an invalid URL. It would help if you included the app code and the form HTML.
In this 2005 forum thread people complain about getting that kind of error on their Blackberries.
I'm on the server side and I can see some Proxy servers trying to access my server with either HTTP/1.0 and no HTTP_HOST (which my app requires) or using the wrong HTTP_HOST.
For example, I am getting requests for widgets.twimg.com , www.google-analytics.com , servedby.jumpdisplay.com . My server doesn't host those domains so the response is obviously not any of the sites on the server, and instead I'm giving back an error.
So, it might be that your Blackberry is not providing the right HTTP_HOST to the server (or none at all) and the server doesn't know what to do with it.
To me, that's Blackberry (or whatever proxy that might exist between you and the server) 's fault.