Problem with TCP/IP (Socket) Connectivity through API Gateway
search cancel

Problem with TCP/IP (Socket) Connectivity through API Gateway

book

Article ID: 110990

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security CA API Gateway

Issue/Introduction

We are having trouble getting access to the data in the request from Tactical Assertion :  "Extensible Socket Connector"

The documentation for the tactical assertion says in the policy ${request.mainpart} should give access to the request data - but this does not work for us. 

We have setup a socket listening on port : 8888 , with message delimiter of x0a (LF) - as per the additional documentation.  And we have test client where we can send in a request and get a response..

The test client sends in a request, the policy is run correctly and a response is returned - but the response ${request.mainpart} is always blank in our test cases. 

Clearly we need access to the request data. 
 

Environment

APi Gateway 9.2 
API Gateway 9.3

With Tactical Assertion :  "Extensible Socket Connector"
 

Cause

It seems the ${request.mainpart} variable is not set unless a new "Validate or Change Content Type" assertion is added to the policy. As detailed below.

 

Resolution

Resolution:
To fill the details into ${request.mainpart} we needed to add an assertion : "Validate or Change Content Type".

It was set to : Change content-type; New value: text/xml (or text/plain - both worked in our testing )
And - this needed to be set : 
       [x] Re-initiaize message The check box on re-initialize is the important one.

Here is screenshot of the response policy that is triggered by the request on the socket.
Highlighted is the "Validate Content Type" with the settings needed to re-calculate the request.mainpart variable: 
 

<Please see attached file for image>

User-added image


The response we have setup is basic echo of the request data, surrounded by X..Y values : 

<Please see attached file for image>

User-added image

Testing the Solution : 
For testing we are using the public domain tool : http://sockettest.sourceforge.net/
It allows us to connect a tcp socket to the backend gateway server on port 8888 and send a \n delimited message: 
 

<Please see attached file for image>

User-added image

We click send the message "TestMessage" to the gateway and get back a response : 

<Please see attached file for image>

User-added image
When it is working then the response we get back is XTestMessageY.

Previously we were getting back an empty string. 

 

Additional Information


Setting up the Extensioble Socket Connector Assertion: 

After installing the "Extensible Socket Connector" Tactical Assertion (it is described fairly well in the documentation that comes with it).  We then setup the policy as follows : 

We manage our Socket Connections (new menu item with this assertion) : 

<Please see attached file for image>

User-added image

And create an inbound assertion called :LFSocket".   Under the general settings tab we set it as an Inbound socket, and the Data Protocol being a terminated message : 

<Please see attached file for image>

User-added image

Under the Inbound settings tab we indicate which socket to listen on 8888, and which policy will be triggered to handle the request. 

<Please see attached file for image>

User-added image

On the Protocol Settings tab, we indicate that 0a (lf) is the message terminator character to be used : 

<Please see attached file for image>

User-added image

We then create the following policy which is triggered for any message arriving on port 8888.

In the policy we are just doing simple things, logging the ${request.mainpart}.  Validating the Content-Type (which is the step we need to add), and then returning a template response. 

<Please see attached file for image>

User-added image

 

Attachments

1558697529561000110990_sktwi1f5rjvs16izp.png get_app
1558697527695000110990_sktwi1f5rjvs16izo.png get_app
1558697525900000110990_sktwi1f5rjvs16izn.png get_app
1558697524275000110990_sktwi1f5rjvs16izm.png get_app
1558697522503000110990_sktwi1f5rjvs16izl.png get_app
1558697520660000110990_sktwi1f5rjvs16izk.png get_app
1558697518293000110990_sktwi1f5rjvs16izj.png get_app
1558697516391000110990_sktwi1f5rjvs16izi.png get_app
1558697514275000110990_sktwi1f5rjvs16izh.png get_app