cancel
Showing results for 
Search instead for 
Did you mean: 

Error : Calling Service Layer through XSJS service issue

0 Kudos

b1slxshttpdest.pngHello Everyone,

I am trying to call Service Layer through my XSJS service but I am stumbling upon the following error : “'HttpClient.getResponse: Can't get the response from the server: internal error occurred "Connection to 10.10.10.11 lost while reading response

I have followed his tutorial which uploaded on YouTube - https://www.youtube.com/watch?v=rqOIWyTjceI (Create and Deploy SAPFiori app 7/8: Demo Service Layer Connect to Service Layer via HANA XSJS)

Below are some facts about the error :

I am seriously trying my best from my side to gather all the evidence related to this weird error which I am stumbling upon while calling Hana Service Layer via XSJS. So while debugging / tracing I have found the below details & this might help you guys to suggest something so that it can help us as a team to fix this issue.

Screenshot 1

Screenshot 3

getorder.txt

As per your reply i have added the code file named as getorder.txt kindly look into it

function GetOrders(appRequest){
    
    var SESSIONID = "";
    var NODEID = "";
    var body;
 
    // SL credentials
    var loginInfo = {};
    loginInfo.UserName = UserName;
    loginInfo.Password = UserPass;
    loginInfo.CompanyDB = UserComp;
    
    // SL LOGIN          
    var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
    
    // B1SESSION and ROUTEID cookies returned by Login
    for (var j in response.cookies){
        if (response.cookies[j].name == "B1SESSION"){
            SESSIONID = response.cookies[j].value;
           output.SessionID = SESSIONID;
        }
        else if (response.cookies[j].name == "ROUTEID") {
            NODEID = response.cookies[j].value;
            output.NodeID = NODEID;
        }
    }
    
    //Get Approval Request Information
    response = slLib.GetOrders(appRequest, SESSIONID,NODEID);
   
    //Parse response body
    body = JSON.parse(response.body.asString());
    
    // Removes metadata
    delete body["odata.metadata"];
    
    //Add Approval Request Decision to Approval Request Body
    //output = body;
    
    output.DocEntry = body.DocEntry;
    output.Message = 'Call de Service Layer ok';
    output.Total = body.DocTotal;
    output.ralph = body.CardCode;
    output.kafhai = body.DocDate;
 
    setOutputMessage();
}

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member390407
Contributor

Hi Abhay,

Nice video I wish everyone described their issues in the same way)

The destination and truststore look ok, the only thing I'm confused with is your path:

You pass the following to your callServiceLayer function as the first parameter: B1SLAddress + 'Login'.

Then you create your request like this: var req = new $.net.http.Request(method, path);

That is equal to: var req = new $.net.http.Request($.net.http.POST, B1SLAddress + 'Login');

I have no clue what B1SLAddress equal to, but your request must be just with Login inside (according to your destination file). So it must be like this:

var req = new $.net.http.Request($.net.http.POST, "Login");

That was the only suspicious place I found in your code.

0 Kudos

Thanks Sergei for the response !!! B1SLAddress is equal to "/b1s/v1/"; If you can Please open "B1SLLogic.xsjslib"file, you can find the very 1st line @ the top !!! Now the weird thing is we are getting the output via postman please find the screenshot of the postman client :

0 Kudos

Now I was trying to analyze the SSL certificate and the info we mentioned in our xshttpdest file, now the certificate was issued to *.aisats.in but in the host we mentioned 10.10.10.11 May be due to this, we might be stumbling upon this error ? If yes then why postman request is working in the first case !!!

Also why while watching that You-Tube Tutorial which you clipped in your blog I came across 1 thing which are as follows, The certificate was issued to *.gitHub.in but in the host he might have mentioned about api.github.com May be due to this, we might be stumbling upon this error ? If yes then why postman request is working in the first case !!!

former_member390407
Contributor
0 Kudos

Abhay,

well, then you call https://10.10.10.11:50000/b1s/v1/b1s/v1/Login and this is probably the reason.

In your destination file you already have this prefix, you don't need to attach it to your url. Please, try to set B1SLAddress to "" (empty string) and try again. Or change the pathPrefix of your destination if you want to specify it in JS.

0 Kudos

Sergei, I modified my code as per your feedback but same error - Can we meet over skype ?

Now I checked the trace file & found something can you have look @ it :

former_member390407
Contributor
0 Kudos

Abhay,

unfortunately I cannot have a skype meeting during the work day. Can you please try to change the following keys in your destination file:

port = 50001;
useSSL = false;

If it works then it means that the problem is on the SSL part.

0 Kudos

Thanks a lot !!!

Yeah its worked using useSSL is false but now i need to figure out how to implement in Production Environment where the useSSL is True.

former_member390407
Contributor
0 Kudos

What do you mean when you say production environment? Is it another server with another address? If you specify trust store the address in your destination file must point to the server in the truststore. If you are developing and testing in the test environment that has a different web-address and different SSL certificate (self-signed probably) you need to upload this particular certificate, not from the live environment.

former_member390407
Contributor

Hi Abhay,

The screenshots weren't attached to your question. Also it would be easier to understand the reason if you share a part of your code where you call the SL (maybe with the destination file).

0 Kudos

Hi Sergei,

As you mentioned I have attached the getOrder.xsjs and B1SL.xshttpdest file as an attachment so please have a look at it and let us know to fix up the issue.

Thanks

former_member390407
Contributor
0 Kudos

Ok, I haven't checked your JS code as I see an error in your destination file. You are trying to access the the port 50000 via HTTP. You need to either set the useSSL option to true and setup the TrustStore for your certificate or call one of load balancing member ports such as 50001.

BTW: I have published a post with an example of how to call SL from XS, where I described the destination part pretty detailed. If you want you can have a look: blog

0 Kudos

Thanks Sergei for looking into our issue, I have tried with the steps which you highlighted in your blog but we are stumbling upon the following error : 'HttpClient.request: request failed: internal error occurred "Failed to send request to socket...rc = -1"'

I have created the video which demonstrates the steps I performed can you please have a look @ it.

Google Drive Video Link

SergioG_TX
Active Contributor

this type of error (failed to send request to socket) sometimes is because the network team has not allowed outbound calls from your HANA environment. I encountered a similar scenario before and I worked with our network team so that they would allow outbound calls (whitelist) from our HANA environment to the destination. Sometimes also needing a specific proxy. hope these 2 clues help your situation

0 Kudos

Thanks for your help !!! I will also discuss about this with my network team.