Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
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 · 2700 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
Alexander Gnauck
AG-Software
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 · 2700 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
Alexander Gnauck
AG-Software
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 · 2700 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();
Alexander Gnauck
AG-Software
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.
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 · 2700 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
Alexander Gnauck
AG-Software
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?
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!
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.
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 SDK Support RSS