Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
danielgielow #1
Member since Apr 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: AgsXMPP Http Proxy
Hi,

I needed configure a proxy in my agsxmpp conection. I looked a lot, but don't found a simple example where i could tell host, port, username and password.

My current connection it is:

  1. static void Main(string[] args)
  2.         {
  3.             XmppClientConnection xmpp = new XmppClientConnection();
  4.             xmpp.Server = "domain";
  5.             xmpp.ConnectServer = "xxx.xx.xxx.xxx";
  6.             xmpp.Username = "user";
  7.             xmpp.Password = "password";
  8.             xmpp.AutoResolveConnectServer = false;
  9.             xmpp.OnLogin += xmpp_OnLogin;
  10.             xmpp.OnError += xmpp_OnError;
  11.             xmpp.OnAuthError += xmpp_OnAuthError;
  12.             xmpp.Open();
  13.  
  14.             lock (xmpp)
  15.             {
  16.                 if (Monitor.Wait(xmpp, 400000))
  17.                 {
  18.                     Console.WriteLine("Connected. Authenticated: " + xmpp.Authenticated);
  19.                 }
  20.  
  21.             }
  22. }
  23.  
  24. static void xmpp_OnLogin(object sender)
  25.         {
  26.             lock (sender)
  27.             {
  28.                 Monitor.Pulse(sender);
  29.             }
  30.         }

Congratulations
Daniel Gielow Junior
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
XMPP is using persistent TCP/IP sockets by default. You can't proxy TCP sockets with the most proxy servers.
HTTP Proxy makes only sense when you use BOSH as transport layer for your connection. Then you can cast the xmppConection.ClientSocket propery to BoshClientSocket and set the Proxy.

Alex
Avatar
danielgielow #3
Member since Apr 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hi,

How can i use BOSH as transport?
You have an example or link for me to see?

I'm starting with a little time XMPP.

Thanks for the help.
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  1. _connection.SocketConnectionType    = agsXMPP.net.SocketConnectionType.Bosh;
  2. _connection.ConnectServer = "http://yourserver.com:5280/http-bind/";

and of course you need a server which supports BOSH.

Alex
Avatar
danielgielow #5
Member since Apr 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Good afternoon Alex,

It's hard to me because i am a beginner.
I try it with a on-line proxy:

            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = "domain";
            xmpp.ConnectServer = "187.85.160.242";
            xmpp.Username = "user";
            xmpp.Password = "password";
            xmpp.AutoResolveConnectServer = false;
            xmpp.OnLogin += xmpp_OnLogin;
            xmpp.OnError += xmpp_OnError;
            xmpp.OnAuthError += xmpp_OnAuthError;

            xmpp.SocketConnectionType = SocketConnectionType.Bosh;
            var bosh = (BoshClientSocket)xmpp.ClientSocket;
            bosh.Address = "173.201.191.190";
            bosh.Port = 80;

            xmpp.Open();

And i get this error:

Invalid URI: The format of the URI could not be determined.


Daniel
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your code is wrong, and you have no URL, only an IP.

  1. XmppClientConnection xmpp = new XmppClientConnection();
  2. xmpp.Server = "domain";
  3. xmpp.ConnectServer = "http://server.com:5280/http-bind/"; // your BOSH Url here only
  4. xmpp.Username = "user";
  5. xmpp.Password = "password";
  6. xmpp.AutoResolveConnectServer = false;
  7. xmpp.OnLogin += xmpp_OnLogin;
  8. xmpp.OnError += xmpp_OnError;
  9. xmpp.OnAuthError += xmpp_OnAuthError;
  10. xmpp.SocketConnectionType = SocketConnectionType.Bosh;
  11.  
  12. xmpp.Open();
Avatar
danielgielow #7
Member since Apr 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Alex,

This is not my case because I have a url.

Thanks for the help.
Avatar
maincoon #8
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
Is there a way to specify login and password for HTTP proxyes? Is URL scheme supports user:password@host/uri format?
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Proxy property of BoshClientSocket is what you are looking for.

Alex
Avatar
maincoon #10
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
OK, hope this should work:

                    case agsXMPP.net.SocketConnectionType.Bosh:
                        // setup connect url
                        connectUrl = "http://" + profile.proxyHost + ":" + profile.proxyPort;
                        // setup credentials for proxy
                        if ( profile.useProxyAuth == true ) {
                            BoshClientSocket sock = xmpp.ClientSocket as BoshClientSocket;
                            sock.Proxy.Credentials = new NetworkCredential(profile.proxyUser, profile.proxyPass);
                        }
                        xmpp.ConnectServer = connectUrl;

How about HttpPolling?
Avatar
maincoon #11
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #9
Sorry, I've found PollClientSocket also. It's all clear now. Thanks!
Avatar
maincoon #12
Member since May 2011 · 13 posts
Group memberships: Members
Show profile · Link to this post
Yep, wrong thread..
This post was edited on 2011-07-05, 11:22 by maincoon.
Avatar
clapou34 #13
Member since Mar 2013 · 4 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
Hi Alex,
I am running through some issue with agsxmpp AND openfire

When I am using both with a Direct communication model ...everything run just smooth
But when I am using Bosh....I cannot register user anymore (while already registered users can connect).

When using Bosh, it seems that the registration feature "<stream:features xmlns:stream="http://etherx.jabber.org/streams"> ....." does not contain "register" element. When using Direct, the "register" element is returned...and the user registration is successful within openfire.

I just cannot understand why communication model could have an impact on the delivered openfire features.

Do you have any idea (I do not think the problem could come from ags....but you perhaps have some idea anyway).
I am posting on both AGSoftware / Openfire forum. Whereever come my issue resolution, both forum will be updated.
Note that I removed all proxy/Load balancers layer...so that only openfire/agsxmpp are involved.

Txs
Christophe
Avatar
Alex #14
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by clapou34:
Do you have any idea (I do not think the problem could come from ags....but you perhaps have some idea anyway).
I am posting on both AGSoftware / Openfire forum. Whereever come my issue resolution, both forum will be updated.
Note that I removed all proxy/Load balancers layer...so that only openfire/agsxmpp are involved.

yes the problem coming from your Openfire server which does not advertise the register feature when you are on BOSH.
Both servers and clients have lots of custom code for BOSH and Sockets. And eg, stream features like TLS are or compression are allowed allowed on socket only. So they are handled in different code on the server and there must be a bug related to the register feature when it does not show up.

Alex
Avatar
clapou34 #15
Member since Mar 2013 · 4 posts
Group memberships: Members
Show profile · Link to this post
Txs Alex for this fast answer.

I will try to gather more info from Openfire and update you if they plan to fix it someday.

Christophe
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