Skip to content

Establishing a connection

Catchbox uses a UDP socket connection for communication between the client and the device.


Attention

No authentication is used with the device and it is expected that the security of the network is ensured to avoid malpractice.

Example below illustrates an example of connecting and sending a command to the Catchbox Hub for node.js

#!/usr/bin/env node
const dgram = require("dgram")

const client = dgram.createSocket("udp4")

// Device information
const device = {
    ip: "192.168.8.35",
    port: "39030"
}

// Command to send
const command  = JSON.stringify({
    "rx": {
        "device": {
            "firmware_info": null
        }
    }
})

// Listen for response 
client.on("message", (message) => {
    console.log("Data received from the device: ", message.toString())
    client.close()
})

// Send the command on defined device ip and port
client.send(command, 0, command.length, device.port, device.ip, err => {
    if (err) {
        console.log(error)
    } else {
        console.log(command + " sent; message length " + command.length)
    }
})

The port used by Catchbox is 39030. You should make sure that the network is set up in a way this port is accessible, i.e., not blocked by firewall.

Please note that the product is capable of communication through IPv4, and, as shown in this example, must use udp4 or equivalent type of connection for the language you've chosen.