Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8503821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:51:40+00:00 2026-06-11T01:51:40+00:00

I am using java playframework2 and it seems that I can not get the

  • 0

I am using java playframework2 and it seems that I can not get the correct ip address with it. It constantly changes after each request.

I mean traffic analytic sites implement javascript in your header to analyse your traffic, so it should be possible with javascript right?

  • If the framework doesn’t provide such a function are there other ways to get the ip from the client?

  • I want to build a visitor counter, but it should only count unique visitors. Maybe I don’t have to use the ip address?

I know that there is http://jsonip.appspot.com/ but it’s to unreliable. I couldn’t use it the last 2 days because it had exceeded its quota on google app engine.

here is my code

public static <T> void increaseViews(String title, String ip,
        Class<T> objClass) throws UnknownHostException, MongoException,
        DbAuthException {
    Logger.info("Ip address: " + ip);
    String ipCache = title + "-" + ip;
    if (Cache.get(ipCache) == null) {
        Cache.set(ipCache, "block", 86400);
        increment(title, objClass);
    }

}

private static <T> void increment(String title, Class<T> objClass)
        throws UnknownHostException, MongoException, DbAuthException {
    // update database
}

and I call it like this:

UserGuides.increaseViews(ug.title, request().remoteAddress(),
                UserGuides.class);

If I follow the logs on Heroku, my ip address is different everytime I reload the page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:51:41+00:00Added an answer on June 11, 2026 at 1:51 am

    Heroku will not directly return the remote address to your play application. Instead what you are seeing is various internal load balancing servers that are part of heroku. However, the good news is that you can easily fix this as per: https://play.lighthouseapp.com/projects/82401/tickets/705-remoteaddress-seems-to-get-dynamically-client-ip-on-heroku

    Simply put: add this to your application.conf

    trustxforwarded=true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Java, how can I detect all of the browsers that are installed on
Using java in one process, how can we create another process that is an
Using Java, how can I test that a URL is contactable, and returns a
Using Java (1.6) I want to split an input string that has components of
By using java reflection, we can easily know if an object is an array.
Using Java (.jsp or whatever) is there a way where I can send a
Using java, I am writting a script to anchor link an html bibliography. That
When using java threads, one has to take care of the basic problems that
Using Java is there anyway to display a custom form/image that behaves similar to
Using java.util.regex.Pattern.compile() you can specify a pattern as parameter. But how can you specify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.