"403 Forbidden" for TIdTCPClient::Connect() + TIdConnectThroughHttpProxy

279 views Asked by At

С++, Embarcadero RAD Studio XE2

I need connect to a ::6100 with TIdTCPClient through http-proxy. So I wrote this code:

    m_pClient = new TIdTCPClient( NULL );

    m_pClient->Host = m_sServerAddress.c_str();
    m_pClient->Port = StrToInt( m_sServerPort.c_str() );
    m_pClient->ConnectTimeout = 5000;
    m_pClient->ReadTimeout = 5000;

    if ( m_bUseProxy == true )
    {
        m_pIdIOHandlerStack = new TIdIOHandlerStack( NULL );

        m_pIdIOHandlerStack->TransparentProxy = new TIdConnectThroughHttpProxy( m_pIdIOHandlerStack );
        m_pIdIOHandlerStack->TransparentProxy->Host = m_sProxyHost;
        m_pIdIOHandlerStack->TransparentProxy->Port = m_iProxyPort;
        m_pIdIOHandlerStack->TransparentProxy->Enabled = True;

        m_pClient->IOHandler = m_pIdIOHandlerStack;
    }
    else
    {
        m_pClient->IOHandler = NULL;
    }

    <other code>

    m_pClient->Connect();

I got an exeption "403 forbidden" on "Connect" proxy: 5.196.0.118::3128
I can connect to this server without proxy or ping it. I used this proxy server successfully with my browser, but I can't use it for my code. How can I resolve this problem?

0

There are 0 answers