PDA

View Full Version : QT Network Proxy Configuration



suresh
15th September 2007, 18:48
Hi,

I,m trying to develop a Messenger. I'm in a LAN and I use a proxy server to coneect to internet. In my application, I set the proxy settings as mentioned int the QNetworkProxy Class reference. But it fails when I try to connect through the proxy, it works fine within the LAN!

I feel the problem is in the proxy settings. Can anyone help me?

Thanks in advance...

wysota
15th September 2007, 19:24
What classes do you use to implement the network part of the application?

suresh
17th September 2007, 15:11
I'm using QTcpServer and QTcpSocket classes for building the network.

In the QNetworkProxy, I'm setting the following details.
QNetworkProxy proxy;
proxy.setHostName("XXX.XXX.XXX.XXX");
proxy.setPort(1080);
proxy.setUser("username");
proxy.setPassword("password");
proxy.setType(QNetworkProxy::HttpProxy); //our network is Http
QNetworkProxy::setApplicationProxy(proxy);

Have to do anything more.

Thanks.

wysota
17th September 2007, 15:59
So what happens if you try to connect? Does the connection try to go through the proxy? Also make sure your proxy object doesn't go out of scope during the lifetime of all the sockets using the proxy.

suresh
17th September 2007, 19:56
Thanks for your reply.

Server is within our LAN. We have one Static IP and whenever a client request for that IP with specific Port number that will automatically re-direct to my Server.
Problem is here. Server is listening properly( listen(QHostAddress::Any, Portvalue) ).

But the Client couldn't be communicate with the Server by requesting to the Static IP/port.
(Client also within our LAN). The same QNetworkProxy have been set in the Client code also.

What should I have to do more in Client code..?

Thanks.

wysota
17th September 2007, 20:18
Please take a network sniffer and inspect the network traffic to determine if clients are connecting to the proxy. Oh, and I assume you did set the proxy on those sockets you want it active for using QAbstractSocket::setProxy()?

suresh
27th September 2007, 16:19
While connecting via QNetworkProxy, the proxyAuthenticationRequired ( QNetworkProxy , QAuthenticator* ) signal is not emitting.

FYI :- Client and Server is within the LAN.

TcpSocket->connectToHost( local IP of Server, PORT);
If we connect through Intranet IP address(like above) it is working fine. Client connects with Server.

TcpSocket->connectToHost( Proxy IP, Port);
If the Connecting Host Address is, our Proxy IP. When we send a request to that IP, that will redirect that request to the server system which is connected with our LAN.
This is not working. The signal proxyAuthenticationRequired() is not emitting.

wysota
28th September 2007, 02:16
So why don't you take a sniffer and do what I said?