开发者

HttpServletRequest.getRemotePort() returns different port per http request received on same machine?

开发者 https://www.devze.com 2023-03-05 08:22 出处:网络
I need to identify the remote ip and port of the clients that register to my service. Also, when the client web app goes down it un-registers itself from my web service.

I need to identify the remote ip and port of the clients that register to my service. Also, when the client web app goes down it un-registers itself from my web service. i am using HttpServletRequest.getRemoteAddress() and HttpS开发者_开发问答ervletRequest.getRemotePort() to identify the clients.

but the problem is when i test on same machine i get different ports from the same client web app.

I am running JAX-WS web service on GlassFish and the Client Web App is also installed on the same container. Also, i am running Fedora 14 VBox VM.


Yes, that's correct, the port used by the connection is never guaranteed to be the same, and as you see, it varies.

The port is decided when the connection is made from the client to the server, and if multiple request are coming on multiple connections, multiple ports appear.

0

精彩评论

暂无评论...
验证码 换一张
取 消