Results 1 to 5 of 5

Thread: TwitterTemplate behind a proxy

  1. #1
    Join Date
    Apr 2011
    Location
    London, UK
    Posts
    2

    Default TwitterTemplate behind a proxy

    Hi

    I'm receiving java.net.ConnectException connection timed out errors when using TwitterTemplate in Tomcat 6 running behind a proxy.

    I've set http.proxyHost and http.proxyPort as system settings and verified they are correct during runtime.

    As I can't really access the restTemplate, is there anything else I could try to make it use the proxy?

    Thanks in advance

  2. #2
    Join Date
    Apr 2011
    Location
    London, UK
    Posts
    2

    Default

    update: still cannot get this to work.

    Using Twitter4Jj as a replacement on same box with same settings works fine.

    Anyone else had any proxy problems here (although it's an assumption really that it's proxy related I guess)??

  3. #3
    Join Date
    Dec 2010
    Posts
    315

    Default

    I have the same issue. I'm unable to set the proxy settings for FacebookTemplate. I tried extending and overriding FacebookTemplate, RequestFactory, and other classes that only lead to confusion.

    I thought why the heck am I doing all these just to set the proxy settings. So I deleted all the classes I did because it doesn't feel right.

    Setting the proxy should be a simple configuration or at least easily accessible.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,067

    Default

    As I said in reply to another thread, there is currently no easy way to configure Spring Social to be used behind a proxy. But this should definitely be addressed. Therefore, I've created https://jira.springsource.org/browse/SOCIAL-146 to track this issue and will be working to resolve it.
    Craig Walls
    Spring Social Project Lead

  5. #5

    Default

    Here is how I passed my &^%&*^%&% NTLM proxy with spring-social milestone 1:

    Code:
    public class FacebookTemplateExt extends FacebookTemplate
    {
        public FacebookTemplateExt(String accessToken, boolean puseProxy, String pproxyUrl, int pproxyPort, String pproxyLogin, String pproxyPwd)
        {
            super(accessToken);
    
            if(puseProxy)
            {
                HttpClient httpclient = ((CommonsClientHttpRequestFactory) (((RestTemplate) restOperations).getRequestFactory()))
                        .getHttpClient();
        
                httpclient.getHostConfiguration().setProxy(pproxyUrl, pproxyPort);
        
                List<String> authPrefs = new ArrayList<String>(2);
                authPrefs.add(AuthPolicy.DIGEST);
                authPrefs.add(AuthPolicy.BASIC);
                // This will exclude the NTLM authentication scheme
                httpclient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
                httpclient.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(pproxyLogin, pproxyPwd));
            }
        }
    I will try to adapt to spring-social M3.

    Ludovic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •