- DarkLight
Authentication
- DarkLight
The client uses any Websocket client credential(s) to connect to the Websocket URL. To connect and access, the client requires Websocket IP address, port, API key and the Secret key.
You can generate the API Key and the Secret Key using the Campaign Manager application. Go to System Menu > API Keys to create new API keys.
Note:
Do store the API Key and the Secret Key when you generate them. You can also generate a fresh set of keys anytime.
Socket Connect
You can send a request to access the Websocket with authentication as below:
wss://PerformanceMetrics_<user>_<unixtimestamp>:base64(apikey:secretkey)@<Websocket URL>:PortNumber/AEDataTransmitter?name=PerformanceMetrics_<user>_<unixtimestamp>
Sample Request
A sample request is reproduced below:
wss://PerformanceMetrics_ACQ_1654268360:MTIzNDUtMTIxMjEyLTEyMTIxMi0xMjEyOjEyMzQ1LTEyMTIxLTIxMjEyLTEyMTItMTIy@dev.aecdevops.com:4747/AEDataTransmitter?name=PerformanceMetrics_ACQ_1654268360
Sample Request Fields
Field | Description |
---|---|
APIKey | A unique code that identifies and authenticates an application to access an API. |
SecretKey | An unique code that is used for authentication purpose. Encode the API Key:SecretKey pair using a Base64 encode utility and use the encoded result in the request. |
WebsocketURL | This is the Websocket URL and the Port. This information varies for each Tenant. |
User | The name of the client requesting access to the Websocket server. |
Unixtimestamp | This is the unique date time field that prevents duplicate logins to the Websocket server.
|
Sample Response
On successful connection, the client receives a connection event. See the response below:
{
"Sender": "Server",
"Receiver": " PerformanceMetrics_ACQ_1654268360",
"MessageType": "OpenID",
"Data": "ec3df1f8b20b4d239354925276a7c989"
}
Sample Response Fields
Field | Description |
---|---|
Sender | The service / component / server sending the response. |
Receiver | The client receiving the response. |
Message Type | This is the authentication type. In this instance, authentication is performed via OpenID. |
Data | This is the Unique ID generated by the Websocket server. |
Initialization Request
When the connection event is received, the client must send an initialization request as below:
[WSEvent] Message:
{
"Sender": " PerformanceMetrics_ACQ_1654268360",
"Receiver": "ATIRealTimeService",
"MessageType": "AEPerformanceMetricInitialization",
"Data": "{\"TimeZoneOffset\":-330,\"Sender\":\"PerformanceMetrics_ACQ_1654268360}"
}
Initialization Request Fields
Field | Description |
---|---|
Sender | The client sending the packet. |
Receiver | The receiver of the packet. |
Message Type | The message type is AEPerformanceMetricInitialization. |
Data | |
TimeZoneOffset | This is the Time zone offset (from UTC) that the client is in. |
Sender | The sender of the packet requesting for initialization. Use the same name you used previously when requesting the Websocket connection.
|
Socket Failure
The connection to the Websocket server is established instantly upon a client’s request, and the authentication is carried out simultaneously. If the authentication fails, the connection established is closed. The failure could be due to an invalid API Key and/or Secret Key. Regenerating the keys should fix the authentication issue.
Other reasons for failure could be:
A wrong Websocket URL sent by the client.
The Websocket server may be down, preventing connection with the client.
Socket Disconnect
The application checks for the connection to the Websocket at 5-second intervals. If there is a disconnect event on the client side, establish the reconnection immediately. On successful reconnection, the client has to send the initialization packet again.