About IP address

879 views
Skip to first unread message

KuoYing@Taiwan

unread,
Dec 16, 2010, 12:09:47 PM12/16/10
to play-framework
I want to get user IP address, I have no idea how to coding.

=> request.headers.get("IP Address???")

nobullet

unread,
Dec 16, 2010, 1:04:14 PM12/16/10
to play-framework
You may look how Nginx <-> Play resolves this problem:

http://technicalhowtos.com/en/pass-ip-from-nginx-to-play-application

Steve Chaloner

unread,
Dec 16, 2010, 1:30:22 PM12/16/10
to play-framework
Http.Request has a remote address string:
Http.Request.current().remoteAddress

- Steve

KuoYing@Taiwan

unread,
Dec 16, 2010, 10:27:25 PM12/16/10
to play-framework
It shows "0" on Page......not IP Address ><"

public static void votes(long id) {
MessageWall messageWall = MessageWall.findById(id); // mesId
ClickLog saveClickLog = new
ClickLog(messageWall.activity,messageWall,messageWall.member,request.remoteAddress).save();
render(messageWall);

tom wen

unread,
Dec 17, 2010, 2:05:59 AM12/17/10
to play-fr...@googlegroups.com
In controller you can use
String clientIp =  request.remoteAddress;

In other you can use
String clientIp = Http.Request.current().remoteAddress;

that's all. it easy!!


2010/12/17 KuoYing@Taiwan <stu93...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.


notalifeform

unread,
Dec 17, 2010, 4:26:41 AM12/17/10
to play-framework


On Dec 17, 4:27 am, "KuoYing@Taiwan" <stu93303...@gmail.com> wrote:
> It shows "0" on Page......not IP Address ><"

Hi,

I noticed the same: request.remoteAddress is '0' if you connect on

http://localhost:9000/

is that a bug?

if I connect on my 'real' ip (e.g http://192.168.1.100:9000/) the
request.remoteAddress is
populated fine.

regards,

Robert

KuoYing@Taiwan

unread,
Dec 17, 2010, 9:19:12 AM12/17/10
to play-framework
Thank You!! I did it^____^

On 12月17日, 下午3時05分, tom wen <wenzhihong2...@gmail.com> wrote:
> In controller you can use
> String clientIp = request.remoteAddress;
>
> In other you can use
> String clientIp = Http.Request.current().remoteAddress;
>
> that's all. it easy!!
>
> 2010/12/17 KuoYing@Taiwan <stu93303...@gmail.com>
>
>
>
>
>
>
>
> > It shows "0" on Page......not IP Address ><"
>
> > public static void votes(long id) {
> > MessageWall messageWall = MessageWall.findById(id); // mesId
> > ClickLog saveClickLog = new
>
> > ClickLog(messageWall.activity,messageWall,messageWall.member,request.remote Address).save();
> > render(messageWall);
> > }
>
> > On 12月17日, 上午2時30分, Steve Chaloner <steve.chalo...@gmail.com> wrote:
> > > Http.Request has a remote address string:
> > > Http.Request.current().remoteAddress
>
> > > - Steve
>
> > > On 16 dec, 18:09, "KuoYing@Taiwan" <stu93303...@gmail.com> wrote:
>
> > > > I want to get user IP address, I have no idea how to coding.
>
> > > > => request.headers.get("IP Address???")
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > play-framewor...@googlegroups.com<play-framework%2Bunsubscribe@go oglegroups.com>
> > .

Dubnobasswithmyheadman

unread,
Dec 17, 2010, 11:37:34 AM12/17/10
to play-framework
Hi,
This could be an IPv6 versus IPv4 connection. Could you try connecting
using an explicit IPv4 address eg. http://127.0.0.1:900/ ?


On Dec 17, 10:26 am, notalifeform <notalifef...@gmail.com> wrote:
> On Dec 17, 4:27 am, "KuoYing@Taiwan" <stu93303...@gmail.com> wrote:
>
> > It shows "0" on Page......not IP Address ><"
>
> Hi,
>
> I noticed the same: request.remoteAddress is '0' if you connect on
>
> http://localhost:9000/
>
> is that a bug?
>
> if I connect on my 'real' ip (e.ghttp://192.168.1.100:9000/) the

notalifeform

unread,
Dec 17, 2010, 1:48:00 PM12/17/10
to play-framework
Hi,


using the code:

public class Test extends Controller {
public static void test(){
renderText("your ip is " + request.remoteAddress );
}
}


http://127.0.0.1:9000/

returns

your ip is 127.0.0.1

http://localhost:9000/Test/test

returns

your ip is 0

Is this a bug (seems like it to me)? should I file it at lighthouse?

regards,

Robert

Guillaume Bort

unread,
Dec 17, 2010, 4:58:03 PM12/17/10
to play-fr...@googlegroups.com
Yes, please report.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.

> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

notalifeform

unread,
Dec 18, 2010, 11:53:55 AM12/18/10
to play-framework
Hi,

I just had the honor to create ticket #500

http://play.lighthouseapp.com/projects/57987-play-framework/tickets/500

regards,

Robert

Ef Rb

unread,
Jan 18, 2011, 3:51:34 PM1/18/11
to play-framework
Is this bug corrected now?
Reply all
Reply to author
Forward
0 new messages