Results 1 to 4 of 4

Thread: QTcpSocket proxy authentication problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTcpSocket proxy authentication problem

    Hi,

    i am trying to make an http request over a proxy server.
    The proxy is ISA proxy server. i use QTcpSocket class

    the IP of destination : xx.xx.xx.xx port : 80
    the IP of proxy server : yy.yy.yy.yy port : 8080

    when i write a code like below:

    Qt Code:
    1. s.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy, "yy.yy.yy.yy",8080));
    2.  
    3. s.connectToHost(xx.xx.xx.xx,80);
    4.  
    5. if (!s.waitForConnected(15))
    6. {
    7. throw s.errorString();
    8. }
    To copy to clipboard, switch view to plain text mode 


    it never connects, throws exception telling "socket timeout"
    I tried setting socket type HttpProxy. it gives exception "Error communicating with HttpProxy"

    then i tried to connect proxy server instead of host :

    Qt Code:
    1. s.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy, "yy.yy.yy.yy",8080));
    2.  
    3. s.connectToHost(yy.yy.yy.yy,8080);
    4.  
    5. if (!s.waitForConnected(15))
    6. {
    7. throw s.errorString();
    8. }
    To copy to clipboard, switch view to plain text mode 

    i put the information about the host into the http request. and post the request to the proxy server. it worked.
    However this only works for anonymous connections.
    So the problem occurs when proxy server requires authentication. I wrote the code below:

    Qt Code:
    1. s.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy, "yy.yy.yy.yy",8080,username,password));
    2.  
    3. s.connectToHost(yy.yy.yy.yy,8080);
    4.  
    5. if (!s.waitForConnected(15))
    6. {
    7. throw s.errorString();
    8. }
    9.  
    10. s.write(requestbytes);
    11. s.waitForReadyRead(-1)
    12. QByteArray response = s.readAll();
    To copy to clipboard, switch view to plain text mode 


    the response was like below with status code 407

    "HTTP 407 Proxy Authentication Required- The ISA Server requires authorization to fulfill the request
    Access to the Web Proxy service is denied
    ..."


    I even used proxyAuthenticationRequired(...) signal and provided the credentials in a slot. but it never enters that slot.
    am i missing something ? what else can i do to achieve authentication to the proxy server?

    thanks..
    Last edited by arbi; 11th September 2009 at 07:58.

Similar Threads

  1. Challenging QTcpSocket reliability problem
    By Raccoon29 in forum Qt Programming
    Replies: 3
    Last Post: 13th January 2009, 10:38
  2. array of pointers to QtcpSocket
    By gQt in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 16th June 2008, 09:15
  3. QTcpServer & QTcpSocket questions...
    By jxmot in forum Qt Programming
    Replies: 2
    Last Post: 24th April 2008, 21:38
  4. QTcpSocket and libssh2 ...
    By sandros in forum Qt Programming
    Replies: 6
    Last Post: 21st November 2007, 22:34
  5. Strange QTcpSocket behavior (debugged with Ethereal)
    By mdecandia in forum Qt Programming
    Replies: 23
    Last Post: 28th May 2007, 20:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.