Home > Enterprise >  What transfer technology is this: "SSL TCP/IP Real Time Connection"?
What transfer technology is this: "SSL TCP/IP Real Time Connection"?

Time:12-15

I'm struggling with this question and did not found information in google, that's why I can't understand what are they talking about.

Please follow,

I was given a https address and a port, this address run a (as they called and I copy here) "TPC/IP using SSL. It's a "real time" protocol, that will give you real time data of the channels you subscribe"

So, I was given a document where they specify how to connect to some channels. It reads:

This protocol is based on JSON format. The default port for this application is XXXXX, and the connection will be established using a SSL TCP-IP connection.

Commands sent and received have the following format: command-id:[message-id[ ]]:[channel]:[data] command-id = Valid commands are LOGIN, JOIN, LEAVE, PING , ACK , ERROR, REPLY, CMD , JSON (mandatory) [message-id] = Identification for message (optional on client) [channel] = channel name for command (optional on client) [data] = Json formated data <-- (this data I copy an example below) (mandatory) All the commands use a \r\n (CR LF) at the end of each line

Example of [data]  = {“user”:”XX”, , ”password”:”YYY”, app”:”ZZZ”, “app_ver”:”zzz” 
”protocol”:”xxx”,”protocol_ver”:”xxxx”}

Also, I provide an example of a complete command:

LOGIN:::{"user":"myname","password":"mypassword","app":"Manual Test", "app_ver":"1.0.0" , 
"protocol":"CustomProtocolABCD", "protocol_ver":"1.0.0"}

Here is what I tried:

Postman, forming the commands, message and data with Parameters, with Body, URL Encoding , everything. I only get "Error: Parse Error: Expected HTTP/" from postman

CURL, tried this also and it prompt me with this odd message "Expected HTTP 1.1 but response is HTTP 0.9". Ok I force this to --http0.9 and I finally get a response with a similar shape:

ERROR:1::{"reason":"Wrong number of parameters"}

Here is the question, How should I test it to send the right amount of parameters the server is expecting? I will provide here below mi CURL with credentials erased of course.

curl https://eu.xxxxxxxxxx.com:11001 -H 'Content-Type: application/json' -k --verbose -d 'command-id:LOGIN' -d 'message-id:100' -d 'channel:' --http0.9 -d 'data:{"user":"XXXXXXX","password":"xxxxxxx","app":"ManualTest","app_ver":"1.0.0","protocol":"CustomProtocolABCD","protocol_ver":"1.0.0"}' -i

NOTE: The password contain a "%" symbol, I don't know if this is generating a problem in the encode but I'm very lost here. Can someone help me pointing any documentation about this kind of communication? I'm really supposed to make an app consuming this information in a embedded device (Qt Creator) but I can't test the endpoint to receive initial json data and then program the app.

Any help is welcomed. Thanks and excuse my english if I made some mistake.

Thanks again

CodePudding user response:

Your data is not a valid JSON string.
This is the post data you are posting:

command-id:LOGIN&message-id:100&channel:&data:{"user":"XXXXXXX","password":"xxxxxxx","app":"ManualTest","app_ver":"1.0.0","protocol":"CustomProtocolABCD","protocol_ver":"1.0.0"}

This part of the post data is valid JSON:

'{"user":"XXXXXXX","password":"xxxxxxx","app":"ManualTest","app_ver":"1.0.0","protocol":"CustomProtocolABCD","protocol_ver":"1.0.0"}

But your header says it the whole body of the packet is Content-Type: application/json

Your actual content is mixed data where the one field data is JSON.
This is the non-JSON part:

command-id:LOGIN&message-id:100&channel:&data:

That looks like a mishmash of post data and JSON combined.



I can only guess but I would think data should look like this:

-d '{"command-id":"LOGIN","message-id":100,"channel":{"user":"XXXXXXX","password":"xxxxxxx","app":"ManualTest","app_ver":"1.0.0","protocol":"CustomProtocolABCD","protocol_ver":"1.0.0"}}'

Which translates to this:

obj(
  'command-id' => 'LOGIN',
  'message-id' => 100,
  'channel' => 
  obj(
    'user' => 'XXXXXXX',
    'password' => 'xxxxxxx',
    'app' => 'ManualTest',
    'app_ver' => '1.0.0',
    'protocol' => 'CustomProtocolABCD',
    'protocol_ver' => '1.0.0',
  ),
)

But I am thinking curl is not a valid protocol for this TCP/IP packet.

You might be able to use curl if you send a body with no header.
Where the body is an SSL encoded packet.

What programming language[s] do you use?
I think I could do this in PHP with sockets and a little better documentation.

CodePudding user response:

Thanks people, the solution is to use

openssl s_client -c connect host.com:11111 

Additionally I had to use \" instead of only " to overcome json encoding in my server.

It was indeed a SSL socket over TCP IP

In Qt I'm using QSslSocket class

Additional information for whoever needs it, this kind of sockets use to have a ping routine where you need to ping the server with a custom command to keep the connection alive.

In Qt I'm programming threads, and one of them will be used to ping the server once connection is established.

Thanks to this awesome community for the support!

  • Related