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

孤人 提交于 2020-01-04 01:51:53

问题


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 HttpServletRequest.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.


回答1:


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.



来源:https://stackoverflow.com/questions/5987456/httpservletrequest-getremoteport-returns-different-port-per-http-request-recei

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!