# Configuration

SocketXP agent uses a configuration file stored at /etc/socketxp/config.json to connect the device with the SocketXP IoT Gateway.

Here is a summary of all the fields in the configuration file with an example value for each field:

{
	"region": "eu",        
	"tunnels" : [           
    {
		"destination": "tcp://127.0.0.1:3000",
		"custom_domain":    "dev.example.com",
		"subdomain":   "my-subdomain",
		"iot_slave":        false,
		"peer_device_id": "1234-abcd-12345-efgh-123545", 
		"peer_device_name": "abcdef12345", 
		"peer_device_port": "22",
		"enable_sshd":  true,
		"ssh_username": "test123",
		"ssh_password": "password123"
	}]
}

You need not set all the fields in the config.json file always. Setting specific fields for specific usecase is recommended, as shown in the examples below.

Note:

Default region is US. Region field should be set to empty string for US region gateway.

You can configure the IoT device name and device group as part of the socketxp login <token> --iot-device-name <name> --iot-device-group <group> command. The device name and device group flags can be set once during the initial device setup. Thereafter if you want to change it, you cannot do so using the login command. You need to edit the device in the web portal page and update its name, group, customer name and location information and save it.

If you make a change to any field in the config file, you need to restart the SocketXP systemd service using the following command:

$ systemctl restart socketxp

Also check the status of the service is "active" and "running" after the restart.

$ systemctl status socketxp

# Configuration file for SSH remote access usecase:

{
	"region": "",        
	"tunnels" : [           
    {
		"destination": "tcp://127.0.0.1:22"
	}]
}

# Configuration file for web app remote access usercase:

{
	"region": "",        
	"tunnels" : [           
    {
		"destination": "http://127.0.0.1:8080",
		"custom_domain":    "dev.example.com",
		"subdomain":   "my-subdomain"
	}]
}

# Configuration file for both SSH and Web app remote access usecase

{
	"region": "",        
	"tunnels" : [           
    {
		"destination": "tcp://127.0.0.1:22"
	},
    {
		"destination": "http://127.0.0.1:8080",
		"custom_domain":    "dev.example.com",
		"subdomain":   "my-subdomain"
	}]
}

# Configuration file for IoT Slave mode access

{
	"region": "eu",        
	"tunnels" : [           
    {
		"destination": "tcp://127.0.0.1:3000",
		"iot_slave":        true,
		"peer_device_id": "1234-abcd-12345-efgh-123545", 
		"peer_device_name": "abcdef12345", 
		"peer_device_port": "22"
	}]
}

# Configuration file for enabling the SocketXP agent built-in SSH server:

{
	"region": "",        
	"tunnels" : [           
    {
		"destination": "tcp://127.0.0.1:22",
		"enable_sshd":  true,
		"ssh_username": "test123",
		"ssh_password": "password123"
	}]
}