Re: about gmail4j using a http proxy

53 views
Skip to first unread message

Tomas Varaneckas

unread,
May 25, 2011, 1:20:40 AM5/25/11
to Bin Pan, gma...@googlegroups.com
It's possible that I couldn't get it to work either. You could try asking people in Gmail4j Google Groups. 

On Tue, May 24, 2011 at 22:36, Bin Pan <bpan...@gmail.com> wrote:
Hi Tomas,
 
Thank you for your reply.
My HTTP proxy does not need any credentials; besides, after adding these
            proxyClient.getState().setProxyCredentials(new AuthScope(proxy_host,proxy_port, null), new UsernamePasswordCredentials("", ""));
I still cannot get it to work.
 
    public Socket createSocket() throws IOException {
        //FIXME doesn't work
        log.debug("Creating socket! with proxy: " + proxy.address());
        ProxyClient proxyClient = new ProxyClient();
        proxyClient.getHostConfiguration().setHost("nmap.gmail.com", 993);
        proxyClient.getHostConfiguration().setProxy("**", 123);
        proxyClient.getState().setCredentials(new AuthScope("172.16.1.99", 993),
                new UsernamePasswordCredentials(TestConfigurer.getInstance().getGmailCredentials().getUsername(),
                        new String(TestConfigurer.getInstance().getGmailCredentials().getPasword())));
        proxyClient.getState().setProxyCredentials(AuthScope.ANY
            , new UsernamePasswordCredentials("tomasv", "***"));
        ProxyClient.ConnectResponse resp = proxyClient.connect();
        return resp.getSocket();
    }
Do you remember whether this proxy functionality ever worked? I would greatly appreciate if you could please point out to me how to achieve connecting to IMAP server through http proxy. If this is all that do the work, I am surprised.
 
Thank you once again!
 
Best regards,
Bin.


 
On Mon, May 23, 2011 at 8:39 PM, Tomas Varaneckas <tomas.va...@gmail.com> wrote:
Hi Bin,

I haven't looked at Gmail4j for quite a while, but hopefully this source code will be helpful, browse around. It's from a project where proxy settings work:


Try setting proxy credentials:

conn.setProxyCredentials(user,
pass.toCharArray());

Hopefully this helps. Good luck!

Tomas

On Tue, May 24, 2011 at 01:40, Bin Pan <bpan...@gmail.com> wrote:
Hi Tomas,
 
I saw your development of gmail4j can handle gmail using IMAP through an HTTP proxy. But I could not get it to work. I tried to send you a message from your webpage; don't know whether you got it or not.
 
Basically, I managed to get java code for ImapGmailClient to work without any proxy server. But when I use the same code behind a proxy server after adding

((ProxyAware) connection).setProxy(proxy_host, proxy_port);

I just cannot get connection to imap server.

On the other hand, using RssGmailClient, I can get it to work after adding

connection.setProxy(proxy_host, proxy_port);

Here, the proxy_host and proxy_port in both places are the same.
 
In the documentation of gmail4j http://www.varaneckas.com/gmail4j/0.3/apidocs/com/googlecode/gmail4j/javamail/ImapGmailConnection.html , it clearly says:

ImapGmailConnection is ProxyAware, allowing to use JavaMail IMAP via HTTP proxy, which was not possible by JavaMail design.
 
Could you please suggest where I did wrong? Thanks a lot.
 
Best regards,
Bin.



Reply all
Reply to author
Forward
0 new messages