Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dynamic header in packager #53

Closed
itraore-TS opened this issue Feb 19, 2020 · 4 comments
Closed

Add a dynamic header in packager #53

itraore-TS opened this issue Feb 19, 2020 · 4 comments

Comments

@itraore-TS
Copy link

Hi I am trying to configure a new header in order to connect with POWERCARD from HPS.
The ISO8583 format is the following :
[ Protocol identification] + [ PowerCARD header ] + [Type of message] + [Bit maps] + [Data fields]
so header look like this : [ Protocol identification] + [ PowerCARD header ] where
[ Protocol identification] = "ISO"
[ PowerCARD header ] =
Position Content
 1-4 Number of characters in the message.
 5 Product code associated with the message. Valid value: ‘2’ = POS
 6-10 The version of the POS software.
 11-13 In case of rejection of message for wrong format, this field must contain the number of the first erroneous element, otherwise it contains "000" If the TPE has messages waiting to be sent to the server, this field must contain "*".

a sample of header will be ISO0413211111000 where [ISO ] + [ 0413 + 2 + 11111 + 000 ]

please can you assist on the way to configure this so the POS sent the message to be routed on the upstream

@juks
Copy link
Owner

juks commented Feb 19, 2020

Hi. You need to use headerFormat parameter to set up the header.

If all of your header values are static, except length, you may set it like so:
--headerFormat=length:n:4,data:an:9:206000000

or you can add extra parameter mode (for the 000 and * thing):
--headerFormat=length:n:4,data:an:9:206000000,mode:an:9

In the second case you need to add mode method that will return the header value in this section:

and implement the logic for your case. But it seems to be impossible now since you do not have this rejection information anywhere.

Looks like this heavy header is set by an upstream not by the client host. Looks really strange.

@itraore-TS
Copy link
Author

itraore-TS commented Feb 21, 2020

I run the script as you proposed on option 1 this is what I have in verbose mode

Your environment has been set up for using Node.js 12.16.0 (ia32) and npm.

C:\Users\source\repos\iso-8583-socket-queue>node socketQueue.js --upstreamHost=46.182.6.101 --upstreamPort=9888 --listenHttpPort=8080 --headerFormat=length:n:4,data:an:9:206000000 --vv --logFile=log.txt
2020-02-21 04:13:06 - info: Important: starting...
2020-02-21 04:13:06 - info: Remote host configuration name: powerCardHPS
2020-02-21 04:13:06 - info: Connecting to upstream server 46.182.6.101:9888
2020-02-21 04:13:06 - info: Relay HTTP server is now running on port 8080
2020-02-21 04:13:06 - info: Connected to upstream 46.182.6.101:9888!
2020-02-21 04:13:06 - info: Processing queue [pending 0 / total 0]
2020-02-21 04:13:06 - info: The queue is empty
2020-02-21 04:13:19 - info: New HTTP socket
2020-02-21 04:13:19 - info: Client http:::1:49164 connected
2020-02-21 04:13:19 - info: Client http:::1:49164 sent data
2020-02-21 04:13:19 - info: http:::1:49164: Warning! Failed to parse iso8583 packet. Won't queue!
2020-02-21 04:13:19 - info: Client http:::1:49164 event

I sent the following http
curl -H "Content-Type: text/plain" -X POST -d '49534F30323539323932303035303030313230307234854108E1880316343038343630313035343034363334333030303030303030303030303039343830303132303132373130333330303036383731323031323731303333343131333032303132373631303330313635343134343230303335333306373030343030303030303030303030383633303034303030313330303430303030303136303132202038484F54454C2054454E455245202020202020202020202020204E69616D657920202020202020000950393230303336353439353210303039393030303030300025303030323030303030303030303431363030303636303130303331344536343142' http://localhost:8080/raw

@juks
Copy link
Owner

juks commented Feb 21, 2020

For this case it takes an option to pass the raw part of client headers as JSON, but there is no such a feature implemented yet.

@itraore-TS
Copy link
Author

Hi Thank you for your help I manage to fix the issue it was as yo just a matter of adding a routine in the header generator. This tools is really powerful thank you for bringing it to our hand.

Please close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants