Proxy
TCXN CCCP Solution
Info
The TCXN CCCP is a solution for applications where a direct connection between a TCP Client and the Thing is needed.
An example of such a situation is when an external SCADA system needs to connect directly to the units that the TCXN Cloud Connect Thing is hosting.
Devices connect to a specific port and register themselves by sending their device serial followed by a carriage return.
The Control API is used to start a proxy server for a specific device on a dynamic port.
After a proxy server is started for a device, clients are allowed to connect to the proxy and communicate with the device.
Proxy setup parameters
The proxy is set up by Telenor Connexion Staff with a number of parameters that is adaptable to each customers. Tell Connexion staff if there are special requirements regarding port ranges etc. when setting up the project specific proxy server.
Proxy API
Proxy Control API:
The /on
endpoint
The /on
endpoint starts a proxy server to which a device and client can connect.
GET /on?serial=<device_serial>[&persistent=<true|false>][&ip_whitelist=<ip>,<ip>,...][&timeout=<sec>]
serial=<device_serial>
is the serial number of the device.
persistent=<true|false>
determines whether the proxy server will be persistent. If so, device and client can connect and disconnect
without the proxy shutting down. Any data sent by device or client when the other party is not connected will be thrown away.
A non-persistent proxy will close down as soon as one of the device or client closes the connection to the proxy, possibly
disconnecting the other party if connected.
ip_whitelist=<ip>,<ip>,...
determines the client addresses allowed to connect to the proxy.
timeout=<sec>
Sets a timeout for the client connecting to the proxy, if no client connection has been made within <sec> the proxy is shut down. If a client connection is made, the timeout is cancelled and the proxy will run as normal.
It returns a HTTP status code and JSON body:
200 (OK) { host: <proxy_host>, port: <proxy_port> }
503 (Service Unavailable) { message: "No available ports" }
500 (Internal Server Error) { message: <error message> }
The /off
endpoint
The /off
endpoint stops a proxy server.
GET /off?serial=<device_serial>
serial=<device_serial>
is the serial number of the device.
It returns a HTTP status code and an optional JSON body:
200 (OK)
404 (Not Found)
500 (Internal Server Error) { message: <error message> }
The /status
endpoint
The /status
endpoint returns the status of a proxy server for a device.
GET /status?serial=<device_serial>
serial=<device_serial>
is the serial number of the device.
It returns a HTTP status code and an optional JSON body:
200 (OK) { device_connected: <true|false>, client_connected: <true|false>, transferred:<payload bytes transferred through proxy> }
404 (Not Found)
500 (Internal Server Error) { message: <error message> }
Thing API
Connection to Cloud Proxy
The Thing must first connect to the project specific port of proxy.cloud.tcxn.net
The flow of when the device connects and how it is told to connect, is application specific.
Registration in Cloud Proxy
When the device has connected to the Cloud Proxy, it must introduce itself to the Proxy so that the proxy can connect it to the correct client session.
The format of this is that the Thing sends it´s serial number, followed by the return character.
The Proxy will not acknowledge this.
Example: CLD-123456\r
Proxy usage flow
First Proxy client asks for a Proxy session for a Thing
Second Proxy and Thing sets up their respective sockets towards proxy
Proxy session is now running
Proxy client is done, wants to end session
Performance
The transfer time for a package end to end depends mainly on latencies in mobile network.