Open cerickson1492 opened 8 years ago
Hi, I assume you are referring to this one, http://stackoverflow.com/questions/32578424/xml-serialisation-error-when-connecting-to-xmpp-server/32578743. I need to create a Sharp.Xmpp stackoverflow area.
I just faced the exact problem the user is having and I know the why and the solution.
The user is connecting to a TLS server which does not support the STARTTLS extension. In this case, the stream must be surrounded with an SSL stream, negotiate the authentication and from there the process remains unchanged.
I have done myself these modifications:
1-modify the tls bool from the core to an enum with None,StartTLS,TLSSocket and refactor all referent changes 2-If tls is TLSSocket surround the stream at XmppCore.Connect and authenticate it with the host name as target srever 3-Else continue with normal process
I can share the project but I did not docummented nothing...
Cheers.
Thanks @agimenezwally . If you don't mind please share the code. I must have gotten confused with all the libraries I was looking at. I thought since it was based on S22 that the tls was the "old tls" and not starttls.
Thanks for the help!
Beware, my project is modified to work with google cloud messaging, I needed to allow null Jid's on messages, expose the Xml utilities and some modifications more I to do it "swallow" the messages from cloud. I'm going to compress it and upload to dropbox.
In case you want to know how to compose the message for GCM here it is:
public void SendDownStream(GCMDownStream Message)
{
Message.message_id = Guid.NewGuid().ToString();
Message.dry_run = true;
string payload = JsonConvert.SerializeObject(Message);
var msg = Sharp.Xmpp.Xml.Element("message");
var elem = Sharp.Xmpp.Xml.Element("gcm", "google:mobile:data");
Sharp.Xmpp.Xml.Child(msg, elem);
elem.Text(payload);
xc.SendMessage(new Sharp.Xmpp.Im.Message(new Message(data: elem)));
}
Also I have added a property called "UseRooster", you must set it to false or it will block waiting a response from the server which will never arrive.
Thank you @agimenezwally that is what I am doing as well. I will look at your code and implement accordingly.
I appreciate the help!
@agimenezwally you are welcomed to make a pull request, especially for the parts that don't conflict with the standard!
Hi @pgstath
I'm not sure which parts conflict with the standar. If you mean with the standard XMPP protocol, none of the changes conflict with it as GCM uses pure XMPP, but the way I implemented it is really ugly, I mean, actually there's no mechanism to create a message with a custom payload (it's always surrounded with a body at least on the current implementation), so i had to expose internal classes (XML namespace), expose the internal constructor of IM.Message "public Message(Core.Message message)" and comment the jid checking on the message, so as I said is very ugly (the part of the TLS and the UseRooster is well implemented :D).
But I'm open to help to create such mechanism, that would be great to expose an api well formed to create custom messages with a payload from an XML element.
What do you think?
Ok, I think I managed to do something acceptable:
1-Added a new constructor to IM.Message which allows to create a message from an XmlElement 2-Left the Xmpp.Xml namespace public to allow to use the functions to create/append Xml elements 3-Implemented a new event named BodylessMessage which receives messages with no body 4-BodylessMessage uses MessageEventArgs, for that I created a new constructor which does not require a Jid as these messages come without an ID (they come from the server itself, not from an user) 6-Created a property on the connection to disable roster retrieval when connection is created. 7-Created a public function to send a default Presence stanza as the usual with no roster is to not send the presence, but in case some service uses it without roster the function is available. 8-Changed Tls from bool to enum, this allows to use StartTLS extension or Ssl sockets.
Also, I have updated the references from ARSoft.Tools.Net, the new references change the DNS resolution (instead of strings they use now a DomainName class).
If all of this looks good to you I can create a pull request to do the review.
Cheers.
Hi, Yes points: 1,2,4,5,6,8 and the ARSoft.Tools.Net update look quite good. In principle I also agree with the need to provide an easy way to built custom stanzas, thus public Xmpp.Xml. I will take a look if 3 can be included in the Message event. So please create the peer request! Regards
Just checking how this is coming along, as I'm interested in this myself.
Cheers
Hello, I am having the same issue:
' ', hexadecimal value 0x15, is an invalid character. Line 1, position 1.
I found 1 answer on this topic:
I am attempting to connect to Google GCM/CCS. I am very new (yesterday) to xmpp but in playing with the agXMPP client I am betting it has something to do with sasl. I added the s22.sasl lib but I am not exactly sure how I would incorporate it or if it will even work with your fork.
Any guidance would be appreciated.
My code is just a slightly modified getting started example using tls and a port to set the client: ` string hostname = "gcm-preprod.googleapis.com"; int port = 5236; string username = "[projectid]@gcm.googleapis.com"; string password = "[api key]"; bool tls = true;