0

I'm getting a error when accessing Tririga OSLC api via secure gateway from my nodered instance in my bluemix space. The Tririga server is hosted in my office at Pune, India. Bluemix zone is US-South.

Error:

Error: socket hang up : cap-sg-prd-3.integration.ibmcloud.com:15343/tririga/oslc/spq/triAllParkingLotsQC?oslc.select=*&oslc.where=spi:cstSensorId=15 

SyntaxError: undefined:1 Error: socket hang up :  ^ Unexpected token E

There are no issues when access the URL with postman. Is this something to do with link speeds between two DCs? The speed test of the Bluemix gateway shows 200ms latency for both up and down links.

Some more information: I did a sample application to remove Tririga out of the question. At bottom you can see my sample node app code that runs on same Tririga server. I created a new destination in the gateway service and tried to access the api via NodeRed flow using the Gateway host and port for the new destination. This api too has the same issue.

Error: socket hang up : cap-sg-prd-3.integration.ibmcloud.com:17451/inventory

I see both console logs of the below server request '/inventory' printed in my on-premise server console.

var express = require('express');

// create a new express server
var app = express();

var inventories= [
  { city : 'Beijing', quantity : 1000},
  { city : 'Shanghai', quantity : 500},
  { city : 'Guangzhou', quantity : 1000},
  { city : 'Shenzhen', quantity : 800}
];

//Get the inventory data
app.get('/inventory', function(req, res) {
  console.log("Request received");
  res.send({"code":1000, "inventory":inventories});
  console.log("Request sent");
});

app.listen(8000, function() {
   //print a message when the server starts listening
  console.log("server started on 8000");
});

One more observation is that http://cap-sg-prd-3.integration.ibmcloud.com:17451/inventory can be accessed over browser or postman without any problem.

ralphearle
  • 1,696
  • 13
  • 18
  • Is your Secure Gateway Client generating any logs when you make this request? – Galen Keene Sep 07 '16 at 13:35
  • Hi Galen, I'm on tracing log level. What is see a repeated client log like below. [2016-09-07 16:06:50.429] [INFO] (Client ID 1tndU6uPzOP_5Ay) Connection #179 is being established to 10.46.40.145:8001 [2016-09-07 16:06:50.491] [INFO] (Client ID 1tndU6uPzOP_5da) Connection #177 to 10.46.40.145:8001 was closed [2016-09-07 16:06:50.913] [INFO] (Client ID 1tndU6uPzOP_O0L) Connection #136 is being established to 10.46.40.145:8001 [2016-09-07 16:06:51.194] [INFO] (Client ID 1tndU6uPzOP_5Ay) Connection #179 to 10.46.40.145:8001 was closed – Lahiru Karunatilake Sep 08 '16 at 10:52
  • Ok, so the client isn't reporting any errors. What version of the client are you using and when did you download the installer/pull the docker image? – Galen Keene Sep 08 '16 at 17:40
  • I was using the installer for Windows – Lahiru Karunatilake Sep 13 '16 at 09:27

1 Answers1

1

Thanks Galen. I figured out the cause. By adding keep-alive header I managed to resolve the issue. For being precise I added following to my Node Red function before calling URL.

[{"id":"ef815a6f.f94ed8","type":"function","z":"280728a8.c953b8","name":"Tririga session","func":"\nvar get_headers = flow.get(\"get_headers\");\n\nif (get_headers === null) {\n var sessionid = msg.headers['set-cookie'];\n msg.headers = {\"connection\":\"Keep-Alive: timeout=15, max=100\",\"cookie\":sessionid};\n flow.set(\"get_headers\",msg.headers);\n \n}\n\nmsg.statusCode = \"\";\nmsg._msgid = \"\";\n\nreturn msg;","outputs":1,"noerr":0,"x":1697.9458847045898,"y":142.6542739868164,"wires":[["f110f408.7fc428"]]}]