Closed manikmagar closed 2 years ago
Getting the IP address of the client is a bit difficult right now as saving the connection object is not considered a good idea with servlets. You can get the headers and query string from the initial connection but not the client's ip currently.
You can place a reverse proxy and pass the client's ip in a header like X-Forwarded-IP
. In this case, you can get the IP from the initial headers by calling the method getInitialHeaders
I'll take this as a feature request and try to add this information somewhere.
Thanks! getInitialHeaders
seem to be available on v3 of this library but not on v2 (Maven version 1.x). By feature request, do you mean for backporting initial headers support to 1.x library?
v4 will be released which will be backward compatible with v1. You can update the library to that version if you don't want to update the frontend library version. Since v4 will be backward compatible with all previous versions, a backport will not be necessary.
Thats a good news! I can't upgrade frontend library version. Any thoughts on when that is planned to be released?
I've published version 4.0.0 to maven and it should be available in a few hours. This version is compatible with all versions of the socket.io-client package at the moment.
There are also some restructure to the packages, particularly around the Emitter
class that you'll need to patch in your source code.
Please try out the new release and let me know if you run into any issues.
I am using 1.0.3 version of this library (with engine.io server 1.3.5) that supports Socket.io v2. I am looking to get the ip address of the connected client. V2 Server API documentation https://socket.io/docs/v2/server-api/#sockethandshake, suggests that
socket.handshake.address
should provide the ip of the client. But I can't see that in this library. Any pointers for this? Thanks!