Overview of the Leap Edge socket for Plug
wss://leap.hop.io/ws
. The IP address behind the hostname is
announced by the Hop anycast network, so you should be connected to the closest
PoP.
Messages with LE are exchanged through a series of opcodes, documented below.
All messages sent from LE are formatted with the following payload type:
encoding
and
compression
. Refer to the below table for possible values.
Parameter | Possible Values | Default |
---|---|---|
encoding | etf , json | json |
compression | zlib , none | none |
json
encoding type will just send plaintext minified JSON
objects.
rx = receive (from LE, to client)
tx = transmit (from client, to LE)
Opcode | Title | Direction | Description |
---|---|---|---|
0 | Dispatch | rx | Used to dispatch events to clients |
1 | Hello | rx | Sent by Leap Edge when connecting with setup info |
2 | Identify | tx | Sent by clients after Op 1: Hello with identifying data (e.g. token) |
3 | Heartbeat | both | Sent on the heartbeat interval by the client; also sometimes sent by LE for requesting HB packet from client |
4 | Heartbeat Ack | rx | Heartbeat acknowledgement |
wss://leap.hop.io/1.0/ws?encoding=json
.
Once connected, you should receive an Op 1: Hello
payload, which contains setup information about the LE session for the client to
use, which includes the heartbeat interval:
4002: Identify timeout
error.
4007: Out of sync
.
Leap Edge may also send Op 3 down to the client with a tag
in the data field.
If the client receives this, it needs to immediately respond with Op 3:
Heartbeat with the same tag
in the data field.
code | description | explaination |
---|---|---|
4000 | unknown | Unknown error. Try reconnecting |
4001 | Invalid auth | You sent an invalid auth token in Op 2: Identify |
4002 | Identify timeout | Client did not send Op 2: Identify within the 10 second window |
4003 | Not authenticated | You sent a service payload prior to Op 2: Identify |
4004 | Unknown opcode | You sent an invalid or undefined opcode |
4005 | Invalid payload | You sent a badly formatted payload |
4006 | Bad route | The server has determined that you have a bad network route to Leap Edge. The error reason will be a new socket endpoint which you should use to reconnect with, instead of using the default endpoint. Not all implementations need to abide by this |
4007 | Out of sync | You have drifted too far outside of the heartbeat interval, or failed to respond to a heartbeat request in time. Reconnect. |