Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Sheshagiri #1
Member since Jan 2017 · 13 posts · Location: India
Group memberships: Members
Show profile · Link to this post
Subject: Reconnecting to BOSH Server Getting Remote Server returned an Error (404 Not Found)
Hi,
I have added a logic in OnError Event to Reconnect to the BOSH Server.  The reason is to try connecting to server though server is not available so that whenever next time server is up, connection is established automatically.

However When I am trying to reconnect it I am getting an error  "Remote Server returned an Error (404 Not Found)" for subsequent reconnection though server is up and running.  My code looks like below

  1. private void session_OnError(object sender, Matrix.ExceptionEventArgs e) {
  2.    canReconnect = true;
  3.    Reconnect();
  4. }

Below is the snippet of the code in reconnect

  1. xmpp.SetXmppDomain(DomainName);
  2. xmpp.Port = Convert.ToInt32(5222);
  3. xmpp.Username = "UserName";
  4. xmpp.Password = "UserPassword";
  5. xmpp.Resource = "Resource";
  6. xmpp.Hostname = "HostNameOfServer";
  7. xmpp.KeepAliveInterval=100;
  8. if (SocketConnectionType.ToLower().Equals("bosh")) {
  9.     xmpp.Uri = new System.Uri("httpbinduri");
  10.     xmpp.Transport = Matrix.Net.Transport.Bosh;
  11. }
  12.  
  13. xmpp.OnMessage += new EventHandler<MessageEventArgs>((o, n) => {
  14.     OnNewMessageEvent(o, n.Message);
  15. });
  16. xmpp.Open();

Please let me know any reason for getting above error
This post was edited on 2017-08-04, 16:41 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

I assume this error comes back from the .NET WebRequests and is just forwarded from MatriX.
To get more details we would need a complete stacktrace of the exception, or HTTP logs which you can trace with fiddler or other tools.

Are you using a timer in your logic? When the server is not available its not a good idea to hammer it directly again in every OnError event.
Try it every 30-60 seconds, or even better use an Exponential backoff strategy.

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: MatriX RSS