juks / iso-8583-socket-queue

ISO 8583 gateway
MIT License
194 stars 111 forks source link

Incorrect bitmap length when using binary instead of Hex #61

Closed shoaibjdev closed 2 years ago

shoaibjdev commented 4 years ago

Hi,

When using fixed-b for Field 1 (Bitmap), binary bitmap is generate with extra 3 bytes. Whereas same bitmap in Hex is generated correctly.

Any idea what could be adding extra 3 bytes to bitmap in binary?

juks commented 4 years ago

Hi!

Could you please provide a test case with message?

shoaibjdev commented 4 years ago

Hi Juks, You can take any 0200 and 0210 message and first map Field 1 to Hex with type fixed-b-hex as below '1': { length: 16, name: 'Bitmap', type: 'fixed-b-hex', alias: '' },

then, change Field to binary as below: '1': { length: 16, name: 'Bitmap', type: 'fixed-b', alias: '' },

Now when you take the binary bitmap and compare with hex editor such as https://hexed.it/ it will show generated bitmap in case of binary is of length 19 instead of 16.

Reason I can't paste sample here is on the logs binary characters are not printed correctly.

juks commented 4 years ago

According to this example, this code is outdates. Formats have been refactored, some errors fixed:

https://github.com/juks/iso-8583-socket-queue/tree/master/lib/iso8583/lib/packer

The current names are 'bitmap' and 'bitmap-hex'. What about updating the source?

shoaibjdev commented 4 years ago

Yes, have updated the source and tried with 'bitmap' as well, but same result. Have been looking into the packer bitmap.js as well but can't figure out from where it's adding additional 3 bytes when the bitmap is binary represented.

shoaibjdev commented 4 years ago

Hex Editor (Working) - With JPOS working-binary

Hex Editor (Not Working) - With SocketQueue not-working-binary

juks commented 4 years ago

But these two masks seem to be different in 6 of 8 bytes. Like different fiends are being sent. So it could be not adding of 3 extra bytes but just another field following the mask?

shoaibjdev commented 4 years ago

Doesn't matter the mask bit is on or off, the lenght of the bitmap should be fixed i.e 16 as per packager configuration.

'1': { length: 16, name: 'Bitmap', type: 'binary', alias: '' },

juks commented 4 years ago

The simplest in-place test shows no difference:

node socketQueue.js --upstreamHost=localhost --upstreamPort=5000 --listenPort=2014 --listenHttpPort=8080 --vv --echoServerPort=5000 --testClients=1 --testTargetHost=127.0.0.1 --testTargetPort=2014 --overrides='1:bitmap-hex:8' --dangerous

2020-06-10 21:00:55 - info: Client ::ffff:127.0.0.1:49288 connected                         
2020-06-10 21:00:55 - info: Client ::ffff:127.0.0.1:49288 sent data (53b)                         
2020-06-10 21:00:55 - verbose: [08002220010000800000990000061021005500000183100000001]    

16 bytes (hex): 2220010000800000

node socketQueue.js --upstreamHost=localhost --upstreamPort=5000 --listenPort=2014 --listenHttpPort=8080 --vv --echoServerPort=5000 --testClients=1 --testTargetHost=127.0.0.1 --testTargetPort=2014 --overrides='1:bitmap:8' --dangerous

2020-06-10 21:01:04 - info: Client ::ffff:127.0.0.1:49292 connected                         
2020-06-10 21:01:04 - info: Client ::ffff:127.0.0.1:49292 sent data (45b)                         
2020-06-10 21:01:04 - verbose: [0800........990000061021010400000183100000001]                         

8 bytes: ........