I am trying to authenticate and connect to a url using the node.js sdk tunneler. I am able to authenticate successfully. However, I am facing an error while trying to give the httprequest. This is my error -
Error: both serviceName and schemeHostPort were specified; they are mutually exclusive
at Object.httpRequest (/home/avaneeshramaseshan/Documents/ziti-tunneler-node/node_modules/@openziti/ziti-sdk-nodejs/lib/httpRequest.js:73:10)
at file:///home/avaneeshramaseshan/Documents/ziti-tunneler-node/index.js:18:6 {
code: ‘EINVAL’
}
I am using this piece of code to connect -
ziti.httpRequest(
‘sample.domain.com’, // OpenZiti Service name or HTTP origin part of the URL
‘’,
‘GET’,
‘/auth/api/v1/baseurl?dept=xyz&email=xxxxx@domain.com’, // path part of the URL including query params
[dept:xyz, email:xxxxx@domain.com], // headers
);
Hi @avaneeshramaseshan, welcome to the community! Happy to see you’re trying out the OpenZiti SDK for node. I’m not a node expert. I pulled the source and scanned it for that error. You’ll find it in src/Ziti_https_request.c. Looking in there for that error you can see these bits of code:
// Determine if the serviceName arg was specified
napi_valuetype valuetype;
status = napi_typeof(env, args[0], &valuetype);
if (valuetype != napi_undefined) {
ZITI_NODEJS_LOG(DEBUG, "serviceName is specified");
serviceNameSpecified = true;
}
[... a few lines removed here...]
if (serviceNameSpecified && schemeHostPortSpecified) {
napi_throw_error(env, "EINVAL", "both serviceName and schemeHostPort were specified; they are mutually exclusive");
return NULL;
}
In your example you provided here:
ziti.httpRequest(
‘sample.domain.com’, // OpenZiti Service name or HTTP origin part of the URL
‘’,
‘GET’,
‘/auth/api/v1/baseurl?dept=xyz&email=xxxxx@domain.com’, // path part of the URL including query params
[dept:xyz, email:xxxxx@domain.com], // headers
);
that second parameter to httpRequest your sending is an empty string and that second parameter is the service name to dial. Empty string isn’t going to be undefined so I think that’s the issue. I think you need that to be undefined so that the if check would be satisfied. Try that out?
If that’s not the case, I’ll defer to our node experts – which is not me! Hopefully that helps
@avaneeshramaseshan, Thank you for trying out our OpenZiti NodeJS SDK. We can’t wait to hear what you’re building with it, so drop a note here when you have a moment.
Clint is correct. The SDK currently requires the unused arg to be specified as undefined.
Meanwhile, I’ll open a GitHub issue for the SDK to treat an empty string as equivalent to undefined so the experience you encountered will not be there in the next release of the SDK.