Get Session Client IP Address

Long story short: Is there some way to get the client’s IP address when they send a file via FTP? (It’s not accessed by getTransportInfo… that only works for HTTP) It shows up in the Integration Server logs, so it is obviously being saved somewhere. Currently, our flow starts by a pub.client.ftp:putCompletedNotification trigger, but we are open to using flow invocation if that will allow us to access the IP through pub.flow:getSession. While getSession gives the session ID, I cannot figure out how to get the client’s IP… has anyone here attempted to do this?

Have you tried getTransportInfo when invoking a service directly via FTP instead of via the notification trigger?

getTransportInfo only provides filename and mimetype for FTP invocations…

Ah, yes, that’s right.

My only thought is to find a non-public method in ServerAPI or maybe in the Session class.

This might work for you. A Java service named getClientIP.

try
{
InvokeState is = new InvokeState();
IDataUtil.put(pipelineCursor, “clientIP”, is.getCurrentSocket().getInetAddress().toString());
}
catch (Exception ex)
{
IDataUtil.put(pipelineCursor, “clientIP”, “INTERNAL”);
}

Thanks for the reply! Your code worked nicely and for future reference here is another way I found to get the same data:

// pipeline

Session sessionObject = Service.getSession();
String clientIp = sessionObject.getName();

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
IDataUtil.put( pipelineCursor, “clientIp”, clientIp );
pipelineCursor.destroy();