KNIM Server Connector running on a server fails with "No session cookie available" when calling a workflow on same server

We are running KNIME 5.2.6 and KNIME Server 4.16.9.

I am having a workflow, which calls another workflow on KNIME Server A (one of our 3 KNIME servers A, B, C). This works fine when running this workflow locally. When moving it to our KNIME Server A, the KNIME Server Connector node fails with the error “KNIME Server Connector: Execute failed: Error occurred during login: No session cookie available.”

This failure does not happen, when I would configure the KNIME Server Connector to connect to KNIME Server B, an instance that is not running the workflow that connects to the server. This proves that it is not a problem with the credentials, but rather either

  • with the KNIME AP running on a server and trying to connect to itself
  • with the KNIME Server receiving a request from a KNIME AP running on the same

I tried a few things directly with the failing server-side job of the KNIME workflow, and when I reconfigure the KNIME Server Connector on the fly with “http://localhost:8080/webportal” instead of the normal Server URL of KNIME Server A, it does actually work.

We logged in to our server to see, if this issue is related to networking rules, but with curl we were able to connect to the server itself without any issue.

Any idea how to fix this?

Hi,
Interesting issue. You have, I believe, correctly diagnosed the problem. When you run on the same server you are attempting to call the workflow on, the system (apparently) concludes that it is trying to reach itself through external communications and panics. Likely, if you did the same thing but ran on Server B, trying to connect to Server B, it would similarly fail, but would succeed at contacting server A.

I presume that you don’t want to reconfigure your workflow to use the loopback address all the time.
I believe you could kluge this in the short term with a Try-Catch pair that uses the loopback if the URL fails. Then it would be functional wherever you run it.

I am not sure how to address this elegantly, but I’ll do some research and get back to you. (If others happen to know, please don’t hesitate to scoop me here.)

OOO, this looks relevant. [KNIME Server Connector - No session cookie available - #12 by marvin_kickuth] But you are running versions that are later. I will try to replicate. This could be a regression.

Other information suggests that the Mountpoint Connector will work better for you than the Server Connector.

The Mountpoint Connector is not an option. I just tried it. Although it does support the same output port that I would need for connecting it to a “Call Workflow Service” node, it fails if the mount point I configured in the node is not connected already. That means, it is useless.

I implemented for us now a KNIME Component that works around the issue by wrapping the KNIME Server Connector node and changing the URL, if is discovers that it points to the same host where the workflow is running. It would require that the KNIME server supports both protocols, https and http, because https with localhost is usually not working (no serious certificate would contain “localhost”).

The following Java code does that trick, in case somebody wants to use it:

// system imports
import org.knime.base.node.jsnippet.expression.AbstractJSnippet;
import org.knime.base.node.jsnippet.expression.Abort;
import org.knime.base.node.jsnippet.expression.Cell;
import org.knime.base.node.jsnippet.expression.ColumnException;
import org.knime.base.node.jsnippet.expression.TypeException;
import static org.knime.base.node.jsnippet.expression.Type.*;
import java.util.Date;
import java.util.Calendar;
import org.w3c.dom.Document;


// Your custom imports:
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.URL;
import java.net.MalformedURLException;

// system variables
public class JSnippet extends AbstractJSnippet {
  // Fields for input flow variables
  /** Input flow variable: "server-url" */
  public String v_serverurl;

  // Fields for output flow variables
  /** Output flow variable: "server-url" */
  public String out_serverurl;

// Your custom variables:

// expression start
    public void snippet() throws TypeException, ColumnException, Abort {
// Enter your code here:

String strHostInUrl = null;
String strLocalHostName = null;

try {
	strHostInUrl = new URL(v_serverurl).getHost();
}
catch (MalformedURLException excUrl) {
	new Abort("KNIME Server URL is malformed: " + excUrl.getMessage());
}

// Try Linux style
try {
	strLocalHostName = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException exc) {
	strLocalHostName = System.getenv("HOSTNAME");
	
	// Fall back 1: Try Windows style
	if (strLocalHostName == null || strLocalHostName.isEmpty()) {
		strLocalHostName = System.getenv("COMPUTERNAME");
		
		// Fall back 2: Use localhost
		if (strLocalHostName == null || strLocalHostName.isEmpty()) {
			strLocalHostName = "localhost";
		}
	}
}
	
// Write everything in lower case
strLocalHostName = strLocalHostName.toLowerCase();

String ipAddressFromUrl = null;
String ipAddressFromLocal = null;

try {
	InetAddress inetAddressFromUrl = InetAddress.getByName(strHostInUrl);
	ipAddressFromUrl = inetAddressFromUrl.getHostAddress();
}
catch (UnknownHostException exc) {
	logWarn("Unable to get IP address for host " + strHostInUrl);
}

try {
	InetAddress inetAddressFromLocal = InetAddress.getByName(strLocalHostName);
	ipAddressFromLocal = inetAddressFromLocal.getHostAddress();
}
catch (UnknownHostException exc) {
	logWarn("Unable to get IP address for host " + strLocalHostName);
}

// If hostname has the same IP address as the server we would call, use localhost:8080
if (ipAddressFromLocal != null && ipAddressFromLocal.equals(ipAddressFromUrl)) {
	out_serverurl = v_serverurl.replaceAll("^(https?://)[^/:]+(:\\d+)?", "http://localhost:8080");
}
else {
	out_serverurl = v_serverurl;
}


// expression end
    }
}

A fix in the KNIME code would be appreciated, of course, but I understand that it would take time.

1 Like