Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
raakeshar #1
Member since Aug 2013 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: BOSH via Proxy Server using Openfire
The problem is the MatriX(.NET) cannot connect the BOSH Server through a proxy from client program.
It connects BOSH Server directly to the Openfire but not via proxy server.
We want to connect the BOSH server via proxy server.
We are using OnCreateWebRequest as suggested in previous posts, but that does not seem to help.
The sample code is as follows:

  1. _xmppClient = new XmppClient();
  2. _xmppClient.Compression = false;
  3. _xmppClient.Hostname = null;
  4. _xmppClient.ResolveSrvRecords = true;
  5. _xmppClient.StartTls = true;
  6. _xmppClient.Status = "Online";
  7. _xmppClient.Show = Show.NONE;
  8.  
  9. _xmppClient.OnMessage += xmppClient_OnMessage;
  10. _xmppClient.OnPresence += xmppClient_OnPresence;
  11. _xmppClient.OnError += xmppClient_OnError;
  12. _xmppClient.OnStreamError += xmpp_OnStreamError;
  13. _xmppClient.OnReceiveXml += xmpp_OnReceiveXml;
  14. _xmppClient.OnSendXml += xmpp_OnSendXml;
  15. _xmppClient.OnCreateWebRequest += xmpp_OnCreateWebRequest;
  16.  
  17.  
  18. void xmpp_OnCreateWebRequest(object sender ,WebRequestEventArgs args)
  19. {
  20.     var proxyObject = new WebProxy("127.0.0.1", 8888);
  21.     if (!(String.IsNullOrEmpty(Config.getInstance().ProxyUsername)))
  22.     {
  23.         var credential = new NetworkCredential(
  24.             Config.getInstance().ProxyUsername, Config.getInstance().ProxyPassword);
  25.         proxyObject.Credentials = credential;
  26.     }
  27.  
  28.     args.WebRequest.Proxy = proxyObject;   
  29. }
This post was edited on 2013-08-13, 10:09 by Alex.
Edit reason: fixed code formatting
Avatar
Alex #2
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Webproxy constructor normally expects a URI and not an IP address like you are passing.
See also: http://msdn.microsoft.com/de-de/library/xfsh37cx(v=vs.80).aspx

Have you tried to debug the xmpp_OnCreateWebRequest callback?
Does it hit your code?
Is there an exception in your code?

Do you set the Transport to BOSH?

  1. xmppClient.Transport = Matrix.Net.Transport.BOSH;
Avatar
raakeshar #3
Member since Aug 2013 · 2 posts
Group memberships: Members
Show profile · Link to this post
Alex, thanks a lot for the quick reply.

I have debugged the xmpp_OnCreateWebRequest callback. It is getting called and there is no exception.

Yes i'm setting the transport to BOSH.

Here's the full code i use to setup my client.

  1. _xmppClient = new XmppClient();
  2. _xmppClient.Compression = false;
  3. _xmppClient.Hostname = null;
  4. _xmppClient.ResolveSrvRecords = true;
  5. _xmppClient.StartTls = true;
  6. _xmppClient.Status = "Online";
  7. _xmppClient.Show = Show.NONE;
  8.  
  9. _xmppClient.OnMessage += xmppClient_OnMessage;
  10. _xmppClient.OnPresence += xmppClient_OnPresence;
  11. _xmppClient.OnError += xmppClient_OnError;
  12. _xmppClient.OnStreamError += xmpp_OnStreamError;
  13. _xmppClient.OnReceiveXml += xmpp_OnReceiveXml;
  14. _xmppClient.OnSendXml += xmpp_OnSendXml;
  15. _xmppClient.OnCreateWebRequest += xmpp_OnCreateWebRequest;
  16.  
  17. Jid jid = new Jid(jabberId);
  18. _xmppClient.Password = password;
  19. _xmppClient.Username = jid.User;
  20. _xmppClient.SetXmppDomain(jid.Server);
  21. _xmppClient.Transport = Matrix.Net.Transport.BOSH;
  22. _xmppClient.Uri = new System.Uri(NETWORK_HOST_BOSH);
  23.  
  24. _xmppClient.Open();
           
I will try the webproxy constructor with a URI.
Thank You.
This post was edited on 2013-08-13, 11:44 by 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