DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Binary tcp/ip communication

  • 1.  Binary tcp/ip communication

    Posted 07/11/22 02:09 PM
    My team is integrating with an HSM Thales 8000/9000 from within a MPGW. They prepare the command (which has the first two bytes contains the length of the message in binary) in Gateway script in a data buffer, then use the session.output.write() method to send it to the HSM.

    When they configure the MPGW for the reply to be Passthrough, they can get the response string in the calling tool (PostMan) and see the first nonprintable two bytes as blank then the rest of the printable characters.

    They cannot get that response message to process inside the MPGW!!!
    Please help with whatever needed in the configurations to be able to read that message and process inside the MPGW policy.

    ------------------------------
    Hisham Ibrahim
    ------------------------------


  • 2.  RE: Binary tcp/ip communication

    Posted 07/11/22 03:02 PM
    What is the response type of the response rule for the MPGW?   How are you trying to process it?  Are there any errors in the logs?

    ----------------
    Joe Morgan
    ----------------

    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: Binary tcp/ip communication

    Posted 07/13/22 08:34 AM
    Thank you so much Joseph. 
    The team went in holidays this week. 
    Will get back once they are back. 


    Best Regards,

    Hesham Soultan)






  • 4.  RE: Binary tcp/ip communication

    Posted 07/18/22 08:55 AM
    ++Adding the DP team.
    @Riham Lamei pls lead with Joseph.


    Best Regards,

    Hesham Soultan, Ph. D.
    (AI, IOT, Business Integration)
    BVS Chief Technology Officer
    Tel: 00201557367399





  • 5.  RE: Binary tcp/ip communication

    Posted 07/19/22 09:59 AM
      |   view attached
    Dear Joseph,
    Regarding response type, it is "non-xml".
    I have created request rule(Client to Server) and response rule(Server to client) but in the response rule we get "Network Error" as per the attachment (errorMsgInCaseRqRp) although there is a gateway script that reads response as buffer and transforms it to string as in the below script:
    session.input.readAsBuffers(function (readAsBuffersError, data) {
    var dataInString = data.toString();
    var encPIN = dataInString.substring(2,dataInString.length);
    var context = session.createContext('hsm');
    context.setVar('encPIN', encPIN);
    session.output.write(encPIN);
    });


    ------------------------------
    Riham Lamei
    ------------------------------



  • 6.  RE: Binary tcp/ip communication

    Posted 07/12/22 11:51 AM

    Hi Hisham,

    First the response type of the MPGW must be non-XML.  If you wish to access this data in the DataPower response rule, you should edit the response rule from the Object menu in the navigation (Objects -> XML Processing -> Processing Rule) and enable non-XML processing.  Since the payload is binary I'd assume you would need to access it using a GatewayScript action that can consume non-XML payloads.  You should ensure that other non binary actions that may be in this rule don't access the INPUT context as it will cause a XML parse error.

    Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 7.  RE: Binary tcp/ip communication

    Posted 07/13/22 08:35 AM
    Thank you so much Steve. 
    The team went in holidays this week. 
    Will get back once they are back. 



    Best Regards,

    Hesham Soultan, Ph. D.
    (AI, IOT, Business Integration)
    BVS Chief Technology Officer
    Tel: 00201557367399





  • 8.  RE: Binary tcp/ip communication

    Posted 07/18/22 08:53 AM
    ++Adding the dp team.
    @Riham Lamei pls lead with Steve.

    Best Regards,

    Hesham Soultan, Ph. D.
    (AI, IOT, Business Integration)
    BVS Chief Technology Officer
    Tel: 00201557367399





  • 9.  RE: Binary tcp/ip communication

    Posted 07/19/22 09:59 AM
      |   view attached
    Dear Steve,
    Kindly note that we have tried the mentioned activities, but unfortunatly, we got "Network error" with sub-code "0x00530001" as mentioned in the attached snapshot "errorMsgInCaseRqRp".
    regarding the readAsBuffer script kindly find the below script:
    session.input.readAsBuffer(function (readAsBuffersError, data) {
    var dataInString = data.toString();
    var encPIN = dataInString.substring(2,dataInString.length);
    var context = session.createContext('hsm');
    context.setVar('encPIN', encPIN);
    session.output.write(encPIN);
    });
    Highly appreciate your comments/suggestions


    ------------------------------
    Riham Lamei
    ------------------------------



  • 10.  RE: Binary tcp/ip communication

    Posted 07/19/22 10:36 AM
    Isn't 0x00530001 a timeout?  Do you have the debug logs associated with that transaction?

    ------------------------------
    Joseph Morgan
    ------------------------------



  • 11.  RE: Binary tcp/ip communication

    Posted 08/11/22 07:05 AM
    Dear Joseph,

    Thanks alot for help  actually i tried to connect using gatewayscript and it worked properly.

    ------------------------------
    Riham Lamei
    ------------------------------



  • 12.  RE: Binary tcp/ip communication

    Posted 07/19/22 03:14 PM

    Hi Riham,

    I am puzzled by a "Network error" still being seen by your response rule.  I'd expect you to receive in the logs an "Unable to establish connection" error when a network error is encountered which typically bypasses the response rule and drives your error rule instead.   If your GatewayScript is on the response rule and is being executed, are you getting anything back in this readAsBuffer callback function?  I'd suggest you use the GatewayScript debugger.  You enable the debugger on your DataPower GatewayScript action and you will pause at the first debugger; statement executed in the code which I'd place as the first statement in your callback function.  You can follow how to use the debugger at https://www.ibm.com/docs/en/datapower-gateway/10.0.x?topic=debuggers-troubleshooting-process-gatewayscript.  It's a very useful tool that I'd personally be lost in debugging any GatewayScript program.  Otherwise, I think there is too much required to understand your issue on the community forum.  I'd suggest your open a PMR.  It would be best to include up front a DataPower probe export with one transaction that exhibits this behavior and would also have an export of your MPGW.  Also include an error report which would have the logs associated with the failing transaction.  Have the log level set to debug for this test.  I'd also provide a packet capture to the request rule's routing-url IP (specify in the packet capture config host <the ip of the backend> ) so it will only capture traffic between DataPower and your backend server.  If that url is a https (SSL) url, then on the packet capture, also specify to generate the ssl/tls session key file which you'll find after the packet capture in the logtemp: directory of your domain.  The actual packet capture will be in the temporary directory of your domain.  You should be able to see the request flowing to the backend and if any network issue, instead of a response there should be some packets that would help identify the problem.  Hopefully with this amount of documentation provided with the PMR DataPower support will be able to identify the issue.

    Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 13.  RE: Binary tcp/ip communication

    Posted 08/11/22 07:02 AM
    Dear steve,

    Thanks alot for help  actually i tried to connect using script and it worked properly.

    ------------------------------
    Riham Lamei
    ------------------------------