Not logged in. · Lost password · Register
Forum: agsXMPP RSS
http-binding
Avatar
Sheshagiri #1
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Subject: Unable to catch exception when Openfire server is down
Hi,
   I am using openfire as xmpp server and I am trying to connect to openfire using agsxmpp bosh.  If the openfire server is up and running, the connection is getting established and working perfectly fine.

However when the openfire server is down during the connection, it throws an error Webexception was unhandled.   I couldn't able to catch the Webexception either by using Exception Hanlder(try catch block) or by adding the event to OnError. 

Below is my code sinippet

  1. XmppClientConnection xmpp = new XmppClientConnection();
  2. xmpp.Server = "xmppDomainName specified in the openfire";
  3. xmpp.Port = port;
  4. xmpp.Username = user;
  5. xmpp.Password = pass;
  6. xmpp.Resource = ReadSetting("fromUserResource");
  7. xmpp.ConnectServer = "http://openfireserver:7071/http-bind/";
  8. xmpp.AutoResolveConnectServer = false;
  9. xmpp.OnAuthError += xmpp_OnLoginFailure;
  10. xmpp.OnError += xmpp_OnError;
  11. xmpp.Open();

Please let me know whether I am missing anything or do I need to implement in different. 

Thanking in Advance
Sheshagiri
This post was edited 3 times, last on 2017-08-01, 12:42 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this could be a bug in agsXMPP. Have you looked in the code or debugged it?
Avatar
Sheshagiri #3
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Hi Alex.  Thanks for your quick response.  I have not debugged agsxmpp code.  I just used the agsxmpp.dll in my project.  I will try to download the code and debug it.
Avatar
Sheshagiri #4
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Hi Alex,
When I debug the code I found that issue might be in the OnGetSessionRequestStream method of BoshClientSocket.cs

I am getting the below error in this method.

System.Net.WebException occurred
  HResult=-2146233079
  Message=Unable to connect to the remote server
  Source=System
  StackTrace:
       at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
       at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
       at agsXMPP.Net.BoshClientSocket.OnGetSessionRequestStream(IAsyncResult ar) in c:\Users\sraghunatharao\Downloads\agsXmpp-master\agsXmpp-master\agsxmpp\Net\BoshClientSocket.cs:line 425
  InnerException: System.Net.Sockets.SocketException
       HResult=-2147467259
       Message=No connection could be made because the target machine actively refused it 192.168.116.1:7071
       Source=System
       ErrorCode=10061
       NativeErrorCode=10061
       StackTrace:
            at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
            at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
       InnerException:

When further debugged into issue, req.Connection is null if the openfire server is stopped.  Don't we need to check for the availability of connection before we End the requeststream.
This post was edited on 2017-07-31, 13:38 by Alex.
Avatar
Sheshagiri #5
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Hi Alex,
I have made some changes so that we will not get the Unhandled Web Exception.  Kindly Review and provide your input on this.

Change made is in the method OnGetSessionRequestStream.  Added the condition if (req.Connection != null)

Thanks and regards
Sheshagiri
The author has attached one file to this post:
BoshClientSocket.cs 31 kBytes
You have no permission to open this file.
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
looks fine to me.
Avatar
Sheshagiri #7
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Hi Alex,
Thanks for your review.  I need one clarification.  When I downloaded the source and build the agsxmpp.dll, the file version is coming as 1.3.1.0 where as when I download the agsxmpp.dll directly from the AGS site, the file version shows as 1.0.0.0 

Can you please clarify whether agsxmpp.dll available in the download section of AGS site also uses the same source which is available in github or different source.

Also can you please clarify will there be any Licensing breach if I build the source and use that dll
Avatar
Alex #8
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The latest code is always in SVN. The downloads on the website are outdated.
The license is always GPL, does not matter where you are getting in from and who compiles or modifies it.
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