Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
NullReferenceException: Object reference not set to an instance of an object.    at Matrix.Net.ClientSocket.Send(Byte[] bData)
Avatar
talaviss@gmail.com #1
Member since Aug 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: create a client to chat with facebook
2011-08-14 12:58:05->XmppClientOnSendXmlMatrix.TextEventArgs
2011-08-14 12:58:05->xmppClient_OnErrorSystem.NullReferenceException: Object reference not set to an instance of an object.
   at Matrix.Net.ClientSocket.Send(Byte[] bData)
2011-08-14 12:58:17->XmppClientOnSendXmlMatrix.TextEventArgs
2011-08-14 12:58:17->XmppClientOnSendXmlMatrix.TextEventArgs
2011-08-14 12:59:17->xmppClient_OnCloseMatrix.EventArgs

My client code is as follows:

            xmppClient.OnBeforeSasl += xmppClient_OnBeforeSasl;
            xmppClient.OnError += xmppClient_OnError;
            xmppClient.OnAuthError += new EventHandler<Matrix.Xmpp.Sasl.SaslEventArgs>(xmppClient_OnAuthError);
            xmppClient.OnMessage += new EventHandler<MessageEventArgs>(xmppClient_OnMessage);
            xmppClient.OnClose += new EventHandler<Matrix.EventArgs>(xmppClient_OnClose);
            xmppClient.OnLogin += xmppClient_OnLogin;
            xmppClient.OnSendXml += XmppClientOnSendXml;
            xmppClient.OnReceiveXml += XmppClientOnReceiveXml;
            xmppClient.Show = Matrix.Xmpp.Show.chat;
            xmppClient.Hostname = "chat.facebook.com";
            xmppClient.XmppDomain = "chat.facebook.com";



         
                xmppClient.Send(new Message
                {
                    To = "oren.farber@chat.facebook.com",
                    From = "tal.avissar@chat.facebook.com",
                    Type = MessageType.chat,
                    Body = "Just Testing the XMPP SDK"
                });
       
            xmppClient.Open();
 
            xmppClient.Send(new Message
            {
                To = "firstname.lastname@chat.facebook.com",
                From = "firstname2.lastname2@chat.facebook.com",
                Type = MessageType.chat,
                Body = "Just Testing the XMPP SDK2"
            });
       

            Console.ReadLine();

i'm getting the above error NullReferenceException: Object reference not set to an instance of an object.
   at Matrix.Net.ClientSocket.Send(Byte[] bData)
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The library is all async. When the open call returns it started the process of connecting. You can't send a message directly after open.
Wait until you got the OnRosterEnd event or the first OnPresence event.
You also don't need to add from on outgoing packets. The server stamps all outgoing packets with the correct address.

Alex
Avatar
talaviss@gmail.com #3
Member since Aug 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
I keep receiving not authorized response from facebook

i'm using
   static private void xmppClient_OnBeforeSasl(object sender, Matrix.Xmpp.Sasl.SaslEventArgs e)
        {
            Log("xmppClient_OnBeforeSasl" );
            e.Auto = false;
            e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.DIGEST_MD5;
                 
        }

and
           xmppClient.Username = "myealfacebookusername";
            xmppClient.Password = myrealfacebookpassword";

but recieivng in response

XmppClientOnSendXml<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InRhbGF2aXNzQGdtYWlsLmNvbSIscmVhbG09ImNoYXQuZmFjZWJvb2suY29tIixub25jZT0iQUM2MjNGODYxQ0UyOTlFOENGQTI3QTdERDhFMTExODUiLGNub25jZT0iOGNkN2Y3ZTNjMmU5MDM3NGY1NTJmZTdiZDRiNDc3YmIzNjMyMTQ1MmM1ZmVlNDc3MGNjNGY0NTA5MDQwMWE2MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9jaGF0LmZhY2Vib29rLmNvbSIsY2hhcnNldD11dGYtOCxyZXNwb25zZT00OWJjOTk2NmZjNTAwZWVjMzQ2NGFkNmU2MjhjM2Q3ZA==</response>
2011-08-14 15:18:29->XmppClientOnReceiveXml<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  <not-authorized />

also i have tried:
 
            e.Auto = false;
            e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.X_FACEBOOK_PLATFORM;

            e.SaslProperties = new Matrix.Xmpp.Sasl.Processor.Facebook.
            {
                ApiKey = API_KEY,
                ApiSecret = API_SECRET,
                SessionKey = "220a1692fd81e15165aa930f02.1-xxxxxxxx"   
        };

but still not authorize, maybe beacuse my session  id is expired? how can i fetch easily the session id if i have a desktop client?
Avatar
talaviss@gmail.com #4
Member since Aug 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
ok I solved my problem.

but still when i want to authenticate with FB and perform

http://www.facebook.com/login.php?api_key=myapikey&con…

i recieve back the json

perms=offline_access%2Cxmpp_login&session=%7B%22session_key%22%3A%22ce1f3c8512ef3af17d13fab9.0-694458257%22%2C%22uid%22%3A694458257%2C%22expires%22%3A0%2C%22secret%22%3A%22463df26dc4f995ced459fd708f27e269%22%2C%22base_domain%22%3A%22mydomain.com%22%2C%22sig%22%3A%2208e2a9bde419540095c4cbfa49413b2a%22%7D

from this long http response what sould i assign to the SessionKey parameter?
Avatar
talaviss@gmail.com #5
Member since Aug 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: session_key oAuth 2.0
from what i know Facebook have deprecated the session_key and now with thw oAuth 2.0 mechanism you have to supplu the
access_token

http://developers.facebook.com/docs/authentication/

http://stackoverflow.com/questions/4435692/facebook-gettin…
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
for user&password auth please follow this link to see what your valid credentials should be:
http://www.facebook.com/sitetour/chat.php

for X-FACEBOOK-PlATFORM authentication please read the following:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

Both authentication mechanism work without problems in MatriX.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: