Not logged in. · Lost password · Register
Forum: agsXMPP RSS
XmppCon.OnSocketError
Avatar
hernanJabber #1
User title: Hernan
Member since Aug 2007 · 8 posts · Location: Israel
Group memberships: Members
Show profile · Link to this post
Subject: SocketError at Connection Open
The AGSXmpp is running very well on our app.... But lately I've been getting an OnSocketError event the displays the Following Message:

 Message "Object reference not set to an instance of an object."

THis Error usually happens when an Object is Called out of its scope or when its "Nothing", the Wierd Thing is that it happens right After the OPEN() function of the xmppCon...

At the moment we are making a Login/Registration with the Basic Data (Username@Server.org) for the Jid, so My Question is if there is a trouble with the XMPPConnection that maybe tries to look into another field that we are not subscribing, or something that can lead to this error on the Xmpp Connection process...

Thank you in advance...


HernanJabber
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

its hard to find the problem without having the source code. If you could strip down your code to a basic example we can take a look at it.

Did you try to debug your code with agsXMPP in debug mode?

Alex
Avatar
hernanJabber #3
User title: Hernan
Member since Aug 2007 · 8 posts · Location: Israel
Group memberships: Members
Show profile · Link to this post
Well, Here is My Connect Function: It Seems to work fine.... but then The Server Returns a Socket Error and tell me It Couldn't write to the Socket....

  Public Function Connect(ByVal JidNick As String, ByVal strServer As String, ByVal strUser As String, ByVal strPW As String, ByVal intPort As Integer) As Boolean

        my_Jid = New Jid(JidNick)
        Try
            With XmppCon
                ' For Handling Messages:
                AddHandler .OnMessage, AddressOf XmppCon_OnMessage
                .Status = "Online"
                .Server = strServer
                .Username = strUser
                .Password = strPW
                .Resource = strServer
                .Priority = 10
                .UseStartTLS = True
                .Port = intPort
                If (intPort = 5223) Then
                    .UseSSL = True
                Else
                    .UseSSL = False
                End If
                .UseCompression = False
                .AutoResolveConnectServer = True
                .AutoRoster = True
                .Show = ShowType.chat

                ' For Registering Changes in presence status:
                Dim PG As New agsXMPP.PresenceCB(AddressOf PresenceCallback)
                .PresenceGrabber.Add(my_Jid, PG, Nothing)

                ' For Controlling the Registering Issues:
                AddHandler .OnRegistered, AddressOf XmppCon_OnRegistered
                AddHandler .OnRegisterError, AddressOf XmppCon_OnRegisterError
                .RegisterAccount = False
                ' To Avoid Connection Troubles:

                .Open()
                Thread.Sleep(5000)
            End With
            'RaiseEvent evConnected(1, XmppCon.Status)
            Return True
        Catch ex As Exception
            'RaiseEvent evConnectionFailed(1, ex)
            Return False
        End Try

    End Function

'---------------------------
'To Make an "Automatic Registration" Process I Make The Following modification on an authorization Error:


   Private Sub XmppCon_OnAuthError(ByVal sender As Object, ByVal e As agsXMPP.Xml.Dom.Element) Handles XmppCon.OnAuthError

        Try
            XmppCon.RegisterAccount = True
            Thread.Sleep(5000)
            XmppCon.Open()
            RaiseEvent evFailure(3) ' Authorization Error
        Catch exp As Exception
            RaiseEvent evFailure(4)
        End Try

    End Sub

- This is Just to Try Registration in case of a Login Failure.... is something wrong with this one? the sleep is not to overload the Server with Login Requests of a same user.... but it still comes with a REGISTRATION Error: "Jabber:iq:register" kind of Error.... on the agsXMP.net.Clientsocket.Endconnect.... Why Is THis Happening :/ ???

Thanks

Hernanjabber




I Can't seems to kow whats wrong with the Code.. Maybe I Need to add the IQ fields for the Registration?
Avatar
hernanJabber #4
User title: Hernan
Member since Aug 2007 · 8 posts · Location: Israel
Group memberships: Members
Show profile · Link to this post
Subject: XML Debug
Ok So PLeeease Help on this one Alex.. I'm Lost within Errors that agsXMPP is throwing out and it comes down to the StreamParser... I've been debugging it like Crazy but no CLUE!!! Here is the XML and XMPP Debug File I Made:

20/08/2007 07:45:36 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
20/08/2007 07:45:39 p.m.: <- XMLin <- <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" from="win-openf" xml:lang="en" id="2dd7764d" >
20/08/2007 07:45:39 p.m.: <- XMLin <- <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>
20/08/2007 07:45:39 p.m.: -> XMLout -> <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5" />
20/08/2007 07:45:40 p.m.: <- XMLin <- <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09Indpbi1vcGVuZiIsbm9uY2U9ImhpcURmWXY3eG5MSWFmY3dYcTd6MkE1QXErRHBackFzeGJrSnVaKzgiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
20/08/2007 07:45:40 p.m.: -> XMLout -> <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9IjEzMTAiLHJlYWxtPSJ3aW4tb3BlbmYiLG5vbmNlPSJoaXFEZll2N3huTElhZmN3WHE3ejJBNUFxK0RwWnJBc3hia0p1Wis4Iixjbm9uY2U9IjVkNzYyN2YxZTc5N2M5NzQ3Mjk0MmU3ZjI1NzYzYmE3ZjUyNDU4OWI0OWIwNjExZDAzNTc2ZDIyNmY3MGEyZmQiLG5jPTAwMDAwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvc3Bpa2tvaW0uY29tIixjaGFyc2V0PXV0Zi04LHJlc3BvbnNlPTE1NGFlMWNiZWY3YmQyODU2ODExZjUyZjUyNTYyM2I2</response>
20/08/2007 07:45:40 p.m.: <- XMLin <- <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized /></failure>
20/08/2007 07:45:40 p.m.: -> XMLout -> </stream:stream>
20/08/2007 07:45:45 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
20/08/2007 07:46:01 p.m.: <- XMLin <- <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" from="win-openf" xml:lang="en" id="f371ee1a" >
20/08/2007 07:46:01 p.m.: -> XMLout -> <iq xmlns="jabber:client" id="agsXMPP_1" type="get" to="spikkoIM.com"><query xmlns="jabber:iq:register" /></iq>
20/08/2007 07:46:01 p.m.: <- XMLin <- <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>
20/08/2007 07:46:01 p.m.: -> XMLout -> <iq xmlns="jabber:client" id="agsXMPP_2" type="get" to="spikkoIM.com"><query xmlns="jabber:iq:register" /></iq>
20/08/2007 07:46:01 p.m.: -> XMLout -> <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5" />
20/08/2007 07:46:01 p.m.: <- XMLin <- <iq xmlns="jabber:client" from="spikkoim.com" id="agsXMPP_1" to="win-openf/f371ee1a" type="error"><query xmlns="jabber:iq:register" /><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
20/08/2007 07:46:01 p.m.: Reg_Error -> <query xmlns="jabber:iq:register" /><error xmlns="jabber:client" code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>
20/08/2007 07:46:01 p.m.: -> XMLout -> </stream:stream>
20/08/2007 07:46:06 p.m.: Reg_Error -> <query xmlns="jabber:iq:register" /><error xmlns="jabber:client" code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>
20/08/2007 07:46:06 p.m.: -> XMLout -> </stream:stream>
20/08/2007 07:46:06 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
20/08/2007 07:46:11 p.m.: <- XMLin <- <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" from="win-openf" xml:lang="en" id="f66618ac" >
20/08/2007 07:46:11 p.m.: <- XMLin <- <iq xmlns="jabber:client" from="spikkoim.com" id="agsXMPP_2" to="win-openf/f371ee1a" type="error"><query xmlns="jabber:iq:register" /><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
20/08/2007 07:46:11 p.m.: Reg_Error -> <query xmlns="jabber:iq:register" /><error xmlns="jabber:client" code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>
20/08/2007 07:46:11 p.m.: -> XMLout -> </stream:stream>
20/08/2007 07:46:11 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
20/08/2007 07:46:16 p.m.: Reg_Error -> <query xmlns="jabber:iq:register" /><error xmlns="jabber:client" code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>
20/08/2007 07:46:16 p.m.: -> XMLout -> </stream:stream>
20/08/2007 07:46:16 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
20/08/2007 07:46:21 p.m.: <- XMLin <- <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" from="win-openf" xml:lang="en" id="71a735f5" >
20/08/2007 07:46:21 p.m.: -> XMLout -> <stream:stream to='spikkoIM.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>



You See Any Problem in Here? Well in My APP the XMPP Thread Just DIES :s///

Thank you

HernanJabber
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

you can't Open the connection in the OnAuthError event again because its already open.

set a flag. close the connection properly and then open it again.

Alex
Avatar
hernanJabber #6
User title: Hernan
Member since Aug 2007 · 8 posts · Location: Israel
Group memberships: Members
Show profile · Link to this post
Subject: Hi Alex!!! It doesn't seem to work
Well, I followed your advice... and it seems prety logical too... Now on an AuthError or RegError I First Close the Connection (xmppCon.close()), give it some response time and then try to re-open the connection with the adapted values.... the only thing is that I'm still getting the Same Mistake...

-    ex    {"Unable to write data to the transport connection." }    System.Exception

I've been Trying to Follow the Program into the agsXMPP code and it seems to Fall on the agsXMPP.net.ClientSocket Part... I Still Can't tell who is actually trying to access an Empty socket because all of this is made automatically by the Protocol... plz Help :s

//// Here is a Stack Trace of the Error:

21/08/2007 05:40:46 p.m.: SocketError -> Unable to write data to the transport connection. : STACK_TRACE >>>    at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   at Mono.Security.Protocol.Tls.RecordProtocol.BeginSendRecord(ContentType contentType, Byte[] recordData, AsyncCallback callback, Object state)
   at Mono.Security.Protocol.Tls.RecordProtocol.SendRecord(ContentType contentType, Byte[] recordData)
   at Mono.Security.Protocol.Tls.RecordProtocol.SendAlert(Alert alert)
   at Mono.Security.Protocol.Tls.RecordProtocol.SendAlert(AlertDescription description)
   at Mono.Security.Protocol.Tls.SslStreamBase.BeginNegotiateHandshake(InternalAsyncResult asyncResult)
   at Mono.Security.Protocol.Tls.SslStreamBase.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
   at agsXMPP.net.ClientSocket.Send(Byte[] bData) in c:\documents and settings\hernan\my documents\spikko\spikko_improject\agxmpp\agsxmpp\net\clientsocket.cs:line 553
   at agsXMPP.net.ClientSocket.Send(String data) in c:\documents and settings\hernan\my documents\spikko\spikko_improject\agxmpp\agsxmpp\net\clientsocket.cs:line 519
   at agsXMPP.net.ClientSocket.InitSSL(SecurityProtocolType protocol) in c:\documents and settings\hernan\my documents\spikko\spikko_improject\agxmpp\agsxmpp\net\clientsocket.cs:line 445
   at agsXMPP.net.ClientSocket.InitSSL() in c:\documents and settings\hernan\my documents\spikko\spikko_improject\agxmpp\agsxmpp\net\clientsocket.cs:line 431
   at agsXMPP.net.ClientSocket.EndConnect(IAsyncResult ar) in c:\documents and settings\hernan\my documents\spikko\spikko_improject\agxmpp\agsxmpp\net\clientsocket.cs:line 271

Thanks for the Time Alex ;_)
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  • can you olease make sure that you use the latest code from SVN
  • Which .NET version are you using? From the error message you use the 1.1 libraries. If this is true can you switch to 2.0?
  • Can you please post your Debug XML

Alex
Avatar
hernanJabber #8
User title: Hernan
Member since Aug 2007 · 8 posts · Location: Israel
Group memberships: Members
Show profile · Link to this post
Subject: Socket Error At CONNECTION START
Hi Alex, Well, I Recently Updated Most of the New SVN Code to the AgsXMPP Library I Had (B.T.W, couldn;t you guys post a .zip to download and replace instead of having to go through each file??? thx ;) and Yes, I Checked that all the XMPP events and errors are Handled in my Class...

Now I Get This "Unable to read data from the transport connection" Error At Different Stages, but it ALWAYS COMES :/
SomeTimes I Get It Right After the "Connecting" State...

and Sometimes I Even Get to "Connecting - > Connected - > Authenticating -> .." AND THEN IT Gets Dissconected... I Don;t Know... Maybe the Server Is Rejecting the Connection somehow? I've Tried most combinations of parameters and NOTHING Seems to work.. plz Help :)

Here is the Last XML Debug... it didn't even accomplished the Connection!!!!

22/08/2007 01:57:51 p.m.: -> XMLout -> <stream:stream to='spikko.org' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
22/08/2007 01:58:13 p.m.: XmppCon_OnSocketError: Unable to read data from the transport connection.System : STACK_TRACE >>>    at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   at agsXMPP.net.ClientSocket.Receive() in C:\Documents and Settings\Hernan\My Documents\Spikko\Spikko_IMproject\agxmpp\agsxmpp\net\ClientSocket.cs:line 575
   at agsXMPP.net.ClientSocket.EndConnect(IAsyncResult ar) in C:\Documents and Settings\Hernan\My Documents\Spikko\Spikko_IMproject\agxmpp\agsxmpp\net\ClientSocket.cs:line 272
22/08/2007 01:58:13 p.m.: -> XMLout -> <stream:stream to='spikko.org' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
Avatar
Alex #9
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by hernanJabber:
Hi Alex, Well, I Recently Updated Most of the New SVN Code to the AgsXMPP Library I Had (B.T.W, couldn;t you guys post a .zip to download and replace instead of having to go through each file??? thx ;)
this is one mouse click or one command if you use a  GUI SVN client or console SVN client.

We can't solve your problem until we can see your source and complete logs. Please create a small test case with documentation and attach it to your post. I think this is the only way to locate your problem.

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:
Forum: agsXMPP RSS